发现在模拟器上请求没问题,但是打包之后,请求失败,提示错误信息network error
axios请求
fetch请求
查阅了很多文档后,发现在android9.0以上由于安全性高了,所有不做处理http不能使用,解决方法有如下三种:
1. 降级targetSdkVersion的版本,降到27或27以下
2.服务器请求http改为https (推荐)
3. 兼容http请求
# 在清单文件中设置networkSecurityConfig属性 <manifest ... > <application android:networkSecurityConfig="@xml/network_security_config"> </application> </manifest> # 在res/xml文件夹下创建network_se