收藏
回答

小程序ios移动端,RequestTask.onChunkReceived 回调触发不了咋回事?

小程序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);
}
回答关注问题邀请回答
收藏

2 个回答

  • 空城
    空城
    02-09

    版本号:


    1 微信开发者工具中 (可以) type 是: fetch

    2 真机上 (不可以) type 是: xhr


    02-09
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    02-08
    有用
    回复
登录 后发表内容