我想将 THREE.js 中的示例文件夹中的模块(例如 OBJLoader)导入到我的 Nuxt 项目中。
我可以导入三个主文件夹,但是在尝试导入示例文件夹中的模块时会发生错误。
尝试了官方文档中的这些步骤。
https://trijs.org/docs/index.html#manual/en/introduction/Import-via-modules https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules
我在下面收到错误
语法错误
意外的标记 {
<template>
</template>
<script>
import * as THREE from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
export default{
}
</script>
这是我的 github 存储库https://github.com/ksuhara/ Threejs-test https://github.com/ksuhara/threejs-test
我终于找到了问题所在。
嗯,这与 nuxt 构建系统有关。当使用第三方库时,您应该将它们添加到nuxt.config.js
bild->transpile
数组,因此它可以作为 Babel 的依赖项包含在内。
transpile: [
"three"
]
Ref: https://nuxtjs.org/api/configuration-build#transpile https://nuxtjs.org/api/configuration-build#transpile
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)