概述 在 main.js 中,添加
import Three from 'three'
Vue.use(三)
使用 npm run dev 启动开发服务器。 预期行为 Vue 项目应该可以正确加载。 实际行为 开发服务器发出此警告:
warning in ./src/main.js
7:8-14 "export 'default' (imported as 'Three') was not found in 'three'
并且浏览器的js控制台显示错误:
Uncaught TypeError: Cannot read property 'installed' of undefined
at Function.Vue.use (eval at <anonymous> (app.js:723), <anonymous>:3443:15)
at eval (eval at <anonymous> (app.js:778), <anonymous>:14:45)
at Object.<anonymous> (app.js:778)
at __webpack_require__ (app.js:660)
at fn (app.js:84)
at Object.<anonymous> (app.js:964)
at __webpack_require__ (app.js:660)
at app.js:709
at app.js:712
最佳答案
这是因为 ThreeJS 库中没有默认导出,因此您可以像这样导入所有内容:
import * as Three from 'three';
此外,您不需要 Vue.use
,因为这不是 VueJS 插件。
由于没有默认导出,您可以从 ThreeJS 导入特定部分,如下所示:
import { Scene } from 'three';
关于reactjs - 在 'default' 中找不到导出 'Three'(导入为 'three'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45937831/