我通过Webpack在Vue中使用Three.js并尝试在npm three module的示例文件夹中使用TrackballControl.js . 我一直在阅读如何最好地解决它并在Github上发现this解决方案 .

enter image description here

因此我在其上配置了我的代码并将其解释为创建一个名为three.js的文件 . 使用以下代码:

import * as THREE from 'three'
global.THREE = THREE;

require('three/examples/js/controls/TrackballControls');

module.exports = global.THREE;

并在我的组件中导入它:

import * as THREE from './three'

但是现在我收到了警告

“./three”中未找到“导出'TrackballControls'(导入为'THREE')''导出'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''在'./three'中找不到'三')

哪里出错了,任何指针都会非常感激 .