码代码的李二狗

我们在本地调试的时候,可以使用index.js来开启本地服务,在局域网内运行app。

但是你会发现一旦你脱离了这个局域网就会造成app无法显示

这时候我们使用main.jsbundle

1.在React Native项目根目录下运行 npm start

2.使用curl命令生成 main.jsbundle

  

curl http://localhost:8081/index.ios.bundle -o main.jsbundle

 

在AppDelegate.m中选择使用main.jsbundle 
注释掉 关于index.js的使用

 

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

  

 posted on 2018-04-18 14:01  timeToShow  阅读(809)  评论(0编辑  收藏  举报
thanks