小程序ios移动端,RequestTask.onChunkReceived 这个监听的回调触发不了咋回事?
但是在 Android端和 ios的pc端小程序都可以监听到,咋回事?
function subscribeChatStream() {
const requestTask = wx.request({
url: `${BASE_URL}/sse/subscribe`,
timeout: 60000,
responseType: "text",
method: "get",
enableChunked: true,
header: {
Accept: "text/event-stream",
"Content-Type": "application/json",
"Cache-Control": "no-cache",
authorization: "Bearer " + store.token,
nonce: Math.ceil(Date.now()),
clientType: "mini",
clientVersion: '1.0.0',
timestamp: Math.ceil(Date.now()),
},
data: {
conversationId: store.conversationId,
},
});
// 添加新的监听器
const chunkListener = (res) => {
console.log("接收的数据:", res);
};
requestTask.onChunkReceived(chunkListener);
}

版本号:
1 微信开发者工具中 (可以) type 是: fetch
2 真机上 (不可以) type 是: xhr