尝试调试 React Native 应用程序时如何解决 NetworkError?

rep*_*ocs 5 android reactjs react-native

我正在创建一个 Android React Native 应用程序,除了我尝试调试程序时,一切似乎都运行良好。当我尝试这样做时,该应用程序只是变成一个空白的白屏,Chrome 控制台出现此错误:

Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at ' http://localhost:8081/index.android.bundle?platform=android&dev=true ' 加载失败。

几秒钟后,应用程序崩溃。有谁知道如何解决这个问题?我刚刚开始这个项目,我还没有真正做那么多,所以我不知道为什么这会破坏

mut*_*utp 1

我有同样的错误。我就是这样解决的。

AppDelegate.m中我评论过-

jsCodeLocation = [NSURL URLWithString:@" http://localhost:8081/index.ios.bundle?platform=ios&dev=true "];

并且未注释-

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

这样做是为了在设备上运行。又换回来了 现在可以工作了。