vue 将图片流转换为 base64 的图片 src

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
getVerify() {
  let that = this;
  axios({
    method: "GET",
    url: `http://192.168.7.61:3000/base/BaseApiService/createCaptchaCode?access_token=bjcenter`,
    responseType: "arraybuffer", //这个在请求头里必须加
  })
    .then((res) => {
      return (
        "data:image/png;base64," +
        btoa(
          new Uint8Array(res.data).reduce(
            (data, byte) => data + String.fromCharCode(byte),
            ""
          )
        )
      );
    })
    .then((res) => {
      that.verify = res;
      console.log("res", res);
    })
    .catch((e) => {
      console.log(e);
    });
},

  

posted @   1点  阅读(1820)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
历史上的今天:
2019-06-24 iView的Message提示框
点击右上角即可分享
微信分享提示