我在使用fetch() api时遇到了问题,我使用get method + https,在Android 9中不能工作。在android 7中工作正常。
代码:
fetch('https://facebook.github.io/react-native/movies.json')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
alert(JSON.stringify(myJson));
})
.catch(function (error) {
alert(error);
});
屏幕:Error screen
发布于 2019-04-10 21:30:27
从android 9开始,你必须手动声明你的应用可以向哪个url发出请求。
如果你想快速修复并打开你的应用程序,只需添加你的清单即可:
<application
android:usesCleartextTraffic="true"
...
>
有关更多信息,请查看here
https://stackoverflow.com/questions/55613610
复制相似问题