React Native开发技巧React Native开发经验集

已有swift项目本地引入React Native的bundle

2017-05-26  本文已影响73人  言溪Lee

已有项目中使用RN时,为了用户体验某些功能要求可直接从本地加载,而不是还要等待从网上下载。那怎样把bundle文件放到项目中是个问题,因为一不小心本地图片读取不到,就加载不出来了

react-native bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ./test/ios/bundle/index.ios.jsbundle --assets-dest ./test/ios/bundle
bundle打包结构.png
获取url:
let url = NSBundle.mainBundle().URLForResource("index.ios", withExtension: "jsbundle")
获取path: 
let path = NSBundle.mainBundle().pathForResource("index.ios", ofType: "jsbundle")
上一篇下一篇

猜你喜欢

热点阅读