L.c*_*xue 5 ecmascript-6 reactjs vue.js
概述在main.js中,添加
import Three from 'three'
Run Code Online (Sandbox Code Playgroud)
Vue.use(Three)
使用npm run dev启动dev服务器.预期的行为Vue项目应该加载没有错误.实际行为dev服务器发出以下警告:
warning in ./src/main.js
7:8-14 "export 'default' (imported as 'Three') was not found in 'three'
Run Code Online (Sandbox Code Playgroud)
浏览器的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
Run Code Online (Sandbox Code Playgroud)
这是因为ThreeJS库中没有默认导出,所以您可以导入如下所示:
import * as Three from 'three';
Run Code Online (Sandbox Code Playgroud)
你也不需要,Vue.use因为这不是VueJS插件.
由于没有默认导出,您可以从ThreeJS导入特定部分,如下所示:
import { Scene } from 'three';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5895 次 |
| 最近记录: |