vue 引入第三方库 提示没有 export ‘default’

我使用npm 安装了一个插件three,然后在main.js里添加了

import Three from 'three'
 Vue.use(Three)

然后启动服务npm run dev

dev服务器发出警告

"export 'default' (imported as 'Three') was not found in 'three'

浏览器控制台显示

vue.esm.js?65d7:4342 Uncaught TypeError: Cannot read property 'install' of undefined
    at Function.Vue.use (vue.esm.js?65d7:4342)
    at eval (main.js?1c90:12)
    at Object.<anonymous> (app.js:955)
    at __webpack_require__ (app.js:660)
    at fn (app.js:86)
    at Object.<anonymous> (app.js:1515)
    at __webpack_require__ (app.js:660)
    at app.js:709
    at app.js:712
阅读 18.7k
1 个回答

文档都是摆设

You're also able to leverage ES6 import syntax:
import * as THREE from 'three';

const scene = new THREE.Scene();
...
or if you wish to import only select parts of three.js library, for example Scene:
import { Scene } from 'three';

const scene = new Scene();
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题