前端处理后台返回二进制流乱码图片

2018-12-13  本文已影响0人  yujiawei007
axios.get('/url', {
        responseType: 'arraybuffer'
      }).then(response => {
        return 'data:image/png;base64,' + btoa(
          new Uint8Array(response.data).reduce((data, byte) => data + String.fromCharCode(byte), '')
        )
      }).then(data => {
        this.img = data
      })
上一篇 下一篇

猜你喜欢

热点阅读