javascript - 从 '@react-three/drei/useGLTF' 导入 useGLTF 导致找不到模块 :

标签 javascript reactjs web module react-three-fiber

我已经安装了 react 三纤维 这是一个依赖项

"dependencies": {
"@react-three/drei": "^3.0.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.0",
"drei": "^2.2.21",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"react-spring": "^8.0.27",
"react-three-fiber": "^5.3.18",
"three": "^0.125.1",
"web-vitals": "^0.2.4"

},

然后我运行npm i drei

之后,我尝试导入 useGLTF

import { useGLTF } from '@react-three/drei/useGLTF'

我得到了错误

./src/Components/Three/Scene.js
Module not found: Can't resolve '@react-three/drei/useGLTF' in 'D:\coding\react\mincraft\src\Components\Three'

我决定在 @react- Three/drei/useGLTF 中手动检查该文件 但没有诸如 useGLTF 之类的名称

我需要运行其他东西吗?

最佳答案

该死的。一段时间后,我在 drei/core/useGLTF 中发现了 useGLTF。

import { useGLTF } from '@react-three/drei/core/useGLTF'

关于javascript - 从 '@react-three/drei/useGLTF' 导入 useGLTF 导致找不到模块 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65950660/

相关文章:

javascript - 使用 For 循环 React JS 卡

javascript - 打开 Accordion 负载与事件类

javascript - 使用 react-router 包装 <button >'s in <Link to=' '>

javascript - className= {'container' } 与 className ='container' 有什么区别

web - 为任何 CMS 系统创建 sitemap.xml 的最高效的方法是什么?

javascript - 如何在node.js中循环请求

javascript - 如何根据用户选择设置要显示的表单数量?

javascript - 当输入类型='date'被清除时如何捕获?

android - 汉堡包菜单图标在 Safari 浏览器上看起来很奇怪

javascript - 评论按钮在 jquery 函数中不起作用