从我阅读的内容来看,导入这两个库似乎是解决 WebGL 错误的方法,我遇到了一个错误,似乎公认的解决方案是这样导入:import PIXI, { Graphics } from 'pixi.js-legacy';import PIXI from 'pixi.js';但是,这样做会导致以下问题:/x/y/FILE_PATH: Identifier 'PIXI' has already been declared (2:7)以及重复的标识符: declare namespace PIXI { ~~~~~~~ node_modules/pixi.js/pixi.js.d.ts:4:1 4 declare namespace PIXI { ~~~~~~~ Conflicts are in this file.node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:14:9 - error TS2323: Cannot redeclare exported variable 'VERSION'.14 var VERSION: string; ~~~~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:3408:9 - error TS2323: Cannot redeclare exported variable 'defaultVertex'.3408 var defaultVertex: string; ~~~~~~~~~~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:3414:9 - error TS2323: Cannot redeclare exported variable 'defaultFilterVertex'.3414 var defaultFilterVertex: string; ~~~~~~~~~~~~~~~~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:11929:9 - error TS2323: Cannot redeclare exported variable 'GRAPHICS_CURVES'.11929 var GRAPHICS_CURVES: { ~~~~~~~~~~~~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:13426:9 - error TS2323: Cannot redeclare exported variable 'PI_2'.13426 var PI_2: number; ~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:13434:9 - error TS2323: Cannot redeclare exported variable 'RAD_TO_DEG'.13434 var RAD_TO_DEG: number; ~~~~~~~~~~node_modules/pixi.js-legacy/pixi.js-legacy.d.ts:13442:9 - error TS2323: Cannot redeclare exported variable 'DEG_TO_RAD'.13442 var DEG_TO_RAD: number; ~~~~~~~~~~我是否有任何选项可以在不删除其中一个导入的情况下完成这项工作?
1 回答
智慧大石
TA贡献1946条经验 获得超3个赞
使用导入别名,如下所示:import PIXI as PIXIJS from 'pixi.js'
参考:https ://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Statements/import
添加回答
举报
0/150
提交
取消