ThreeJS导入失败
问题描述
1 |
|
在src.js
中用如下方式导入ThreeJS 1
import * as THREE from 'three';
index.html
body如下 出现报错 1
2
3<body>
<script type="module" src="/src/day01_a.js"></script>
</body>
## 解决方案
stackoverflow给出了解决方案https://stackoverflow.com/questions/65697410/not-using-node-js-uncaught-typeerror-failed-to-resolve-module-specifier-thre1
Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../".
删除src.js
的导入,将index.html
body改为
1
2
3
4<body>
<script src="/node_modules/three/build/three.js"></script>
<script type="module" src="/src/day01_a.js"></script>
</body>
ThreeJS导入失败
https://studyinglover.top/2023/01/13/ThreeJS导入失败/