Win7 React Native真机调试:
进入react-native项目根目录下, react-native start
启动服务;数据线连接真机,react-native run-android
安装并启动react-native项目。
电脑浏览器: http://localhost:8089/index.bundle?platform=android
显示正常
手机显示页面:
![](https://img.haomeiwen.com/i1972602/a24e955a0fe1a00b.png)
设置IP及端口,摇一摇菜单:
![](https://img.haomeiwen.com/i1972602/bf7b7cf0e7202239.png)
Dev Setting
中配置电脑ip和端口:![](https://img.haomeiwen.com/i1972602/9145bc566bf00d20.png)
修改App.js中内容,摇一摇菜单 Reload
,预期页面更新。
然而:
![](https://img.haomeiwen.com/i1972602/07e54b45ee7a8b42.png)
尝试 react-native start --reset-cache
重启服务无效!
尝试 PC浏览器http://localhost:8081/index.bundle?platform=android
正常显示,http://10.200.108.35:8081/index.bundle?platform=android
直接404 !!
原因:
8081端口被占用。
解决:
将react native服务的访问端口改为其他(如8089)启动 react-native start --port=8089
手机上再次Reload
,成功!
![](https://img.haomeiwen.com/i1972602/ccb485719ecf6973.png)
且PC端
http://localhost:8089/index.bundle?platform=android
、http://10.200.108.35:8089/index.bundle?platform=android
均可访问。
网友评论