react native与webapi交互

react native坑太大了!!!
既然跳进去了,就想办法填坑呗~

webapi

本地开启webAPI

webapi

curl测试webAPI

test webapi

react native如何debug

command + d

在ios的simulator上,command+d调出菜单,选择Debug JS Remotely

debug

Runtime is not ready for debugging.

如果报出该错,则需要下载chrome浏览器,mac自带的safari无法载入本地的reactJS文件。

error

Network request failed.

如果报出该错,需要配置xcode里对于http请求的设置。

error

这个错误搞的我烦躁了一个周末,根本没有头绪。
首先,要确认RCTWebSocketExecutor.m文件中host = @”localhost”;

host

其次,要在plist的APP Transport Security Settings中添加Allow Arbitrary Loads为True。这个设置把request请求不仅仅局限于https安全模式,http也被允许了。

plist

chrome debug

测试一下,与本地webapi的交互,在chrome浏览器下可以打断点,查看变量了。

chrome

webapi的监听也收到了request。

webapi listen

退出debug模式

command + d

在ios的simulator上,command+d调出菜单,选择Stop Remote JS Debugging

stop debug

参照facebook debugging文档

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2015-2021 小白兔
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信