react native: No bundle url pres

2019-07-10  本文已影响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>

上一篇 下一篇

猜你喜欢

热点阅读