-
Creator 版本: 3.6.0
-
目标平台: Android studio 以及自带的模拟器api level:30 abi:x86
-
重现方式:初始化一个hellowworld 工程 分别使用fetch 和XMLHttpRequest请求同一个接口。代码使用如下:
requestGetPlayerData() {let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) { var response = xhr.responseText; console.log('requestGetPlayerData res = ', response); console.log('requestGetPlayerData res xhr.responseType', xhr.responseType); // let node = find('Canvas/Label'); // let Label1 = node.getComponent(Label); // Label1.string = Label1.string + ' -- xmrhttp ok:' + JSON.parse(response).data.list[0].activityUrl; console.error('------------end -------------'); } }; let url='http://192.168.10.254:8000/a/b' xhr.open('POST', url); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.send(JSON.stringify({ opType: 1 }));}
requestFetch() {
let options = { method: 'POST', body: JSON.stringify({ opType: 1, ffff: 3 }), headers: { 'Content-Type': 'application/json' }, }; fetch('http://192.168.10.254:8000/a/b', options).then((response: Response) => { console.log('requestFetch Response: ', response); console.log('requestFetch Response v.type: ', response.type); response.json().then((b: any) => { console.log('requestFetch Response json: ', b); // let node = find('Canvas/Label'); // let Label1 = node.getComponent(Label); // Label1.string = Label1.string + ' -- fetch ok:' + b.data.list[0].activityUrl; console.log('------------end requestFetch-------------'); }); });}
-
首个报错:E/ [ERROR] Failed to invoke XMLHttpRequest_getResponse, location: E:/CocosDashboard_1.2.2/resources/.editors/Creator/3.6.0/resources/resources/3d/engine/native/cocos/bindings/manual/jsb_xmlhttprequest.cpp:903
-
编辑器操作系统: windows 10
-
重现概率: 100%
老哥 这个问题你咋解决的?