猿问

无法识别导入文件中的文件

我创建了一个MenuButton以及另外2个页面,其中之一是settingScreen,在这里我已经在两个文件中导入了MenuButton,它们似乎运行良好。但是,当我在DrawerNavigator文件上导入设置Screen时,它无法识别MenuButton


Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Unable to resolve module `./Menu/MenuButton` from `/Users/camillebasbous/Project/Menu/SettingScreen.js`: The module `./Menu/MenuButton` could not be found from `/Users/camillebasbous/Project/Menu/SettingScreen.js`. Indeed, none of these files exist:

  * `/Users/camillebasbous/Project/Menu/Menu/MenuButton(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`

  * `/Users/camillebasbous/Project/Menu/Menu/MenuButton/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)` (null))


__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.228

    RCTCxxBridge.mm:414

___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118

__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke

-[RCTMultipartStreamReader emitChunk:headers:callback:done:]

-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]

-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]

__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke

__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__

-[NSBlockOperation main]

-[__NSOperationInternal _start:]

__NSOQSchedule_f

_dispatch_call_block_and_release

_dispatch_client_callout

_dispatch_continuation_pop

_dispatch_async_redirect_invoke

_dispatch_root_queue_drain

_dispatch_worker_thread2

_pthread_wqthread

start_wqthread

我试过测试另一页,经过几次测试后,我意识到这些页中存在导入的MenuButton是导致错误的原因吗?是否可以导入已导入另一个要显示的文件的方法?将它们都导入drawerNavigation中,如果是,则如何构造代码。谢谢


收到一只叮咚
浏览 313回答 1
1回答

慕少森

导入时使用的路径是相对于文件的。因此,由于所有内容都在同一文件夹中,因此您必须像这样更正导入路径:在Drawer Navigator代码上import SettingScreen from './SettingScreen'在SettingScreen代码上import MenuButton from './MenuButton'
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答