0
我的目录结构是这样的:在导入文件阵营本地
web/
js/
Test.js
mobile
index.android.js
在index.android.js
,我加import Test from '../web/js/Test
。不过,我得到这个错误:
(node:590) UnhandledPromiseRejectionWarning:
Unhandled promise rejection (rejection id: 12):
UnableToResolveError:
Unable to resolve module `../web/js/Test.js` from `/mnt/d/.../mobile/index.android.js`:
Directory /mnt/d/.../web/js/Test.js doesn't exist
我试图重新运行react-native start
,它仍然没有工作。我没有安装Watchman,但我不认为这是问题。
我不知道你在试着克去做。您是否试图在React Native中重复使用您的React网页代码? React Native是否允许您从项目根目录及其嵌套文件夹以外的任何位置导入js文件?看起来你似乎错过了你提到的导入的单引号,尽管这可能是你的错误。另一个问题是如何定义测试。您是否正确导出该组件?我们需要更多信息来确定发生了什么。 – nbkhope