html - GLTFLoader 无法导入模块外
问题描述
随着对 THREE.js 的更新,我在使用 GLTFLoader 时遇到了问题。它不断给我上面提到的错误。
在单独的 js 文件中导入
测试.js
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
索引.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/110/three.min.js"></script>
<script src="test.js"></script>
文件结构
解决方案
The import statement cannot be used in embedded scripts unless the script has a type="module".
Here is an example for the import statement with type module.
<script type="module" src="test.js"></script>
推荐阅读
- c++ - 你怎么能 emplace_back 错误的类型?
- ios - dyld:库未加载:Xcode 更新后的@rpath/libswiftCore.dylib
- asp.net - 提供两个带有一个标头/HTTP 事务的 .csv 文件
- javascript - 动态文件夹内容的图像自动滑块
- c# - 为什么 TcpListener 不监听?
- c# - 从应用商店更新后保留本地数据
- vba - 为什么我会收到方法范围错误?
- javascript - 如何在 Odoo OCA 小部件 web_widget_x2many_2d_matrix 中按序列而不是名称对记录进行排序?
- python - 当文本落在matplotlib的绘图区域之外时如何删除文本?
- android - 如何比较android中的音频?