收藏
回答

decoder.decode(new Uint8Array(res.data)返回乱码?

win7系统 64位 微信开发者工具 wechat_devtools_1.05.2204250_x64

requestTask.onChunkReceived((res) => {

      let decoder = new TextDecoder('utf-8');

      let text = decoder.decode(new Uint8Array(res.data)); 

       

      if (text.indexOf('[DONE]'=== -1{   

        const chat = JSON.parse(text.substring(5));

        if (chat.code === 0{

          const answer = list.find(p => p.type == 1 && p.chatId === chatId);

          if (answer{

            answer.text = [...answer.text, ...this.analysisChat(chat)];

          } else {

            list.push({

              chatId: chatId,

              type: 1,

              text: [...this.analysisChat(chat)]

            })

          }


          this.setData({

            bottomViewId: "view" + this.data.messageId,

            list: list

          });

        }

      } else {

        this.setData({

          loading: false

        })

        console.log("回答完毕");

      }

    });


回答关注问题邀请回答
收藏

2 个回答

  • sun
    sun
    发表于小程序端
    2025-01-25

    建议使用最新版开发工具,目前最新版开发工具已不支持Windows7,需要更新到Windows10以上。总的来说还是建议更新系统。

    2025-01-25
    有用
    回复
  • 前路昭然
    前路昭然
    2025-01-25

    现在情况是同样的代码在同事电脑上没得任何问题,我本地的差异就是微信开发工具不是最新版本,本地环境win7系统更新后开发工具无法打开,所以就没有升级。而工具升级里面有关于SSE相关的,不知道是不是因为工具版本原因导致的

    2025-01-25
    有用
    回复
登录 后发表内容