try {
       const response = await request.get(checkCodeUrl.value,{responseType:"arraybuffer"});
      console.log("验证码请求成功:", response);
   checkCodeUrl.value = `data: image/jpeg;base64,${btoa(new Uint8Array(response).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`;
     } catch (error) {
         console.error("验证码请求失败:", error);
    }

接口上面的responseType设置成为buffer即可

(new Uint8Array(response)-----这里的response替换成为自己的乱码内容所对应的是后端返回的哪一个具体位置

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐