美文网首页
react native: No bundle url pres

react native: No bundle url pres

作者: 半个木头人 | 来源:发表于2019-07-10 11:09 被阅读0次

//  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

将上面的换成下面的:

如果到要真机上测试,127.0.0.1需要换成自己的网络ip。(当然还要有证书)

#ifdef DEBUG

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

#else

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

#endif

此外:上面应该就好了。如果不好,有人说是网络权限问题:

My problem has been solved by adding NSAllowsLocalNetworking to Info.plist

<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

<true/>

<key>NSAllowsArbitraryLoadsInWebContent</key>

<true/>

<key>NSAllowsLocalNetworking</key>

<true/>

</dict>

</key>

相关文章

网友评论

      本文标题:react native: No bundle url pres

      本文链接:https://www.haomeiwen.com/subject/dumckctx.html