axios异步获取文件流数据

axios异步获取流程图片流文件进行图片

var _this = this
var url = _this.host
axios({
        method: 'GET',
        url: url,
        headers: {
          auth: _this.auth
        },
        responseType: 'arraybuffer'
      })
        .then((response) => {
          return (
            'data:image/png;base64,' +
            btoa(
              new Uint8Array(response.data).reduce(
                (data, byte) => data + String.fromCharCode(byte),
                ''
              )
            )
          )
        })
        .then((response) => {
          this.src = response
        })
        .catch(function (error) {})

  

 
原文地址:https://www.cnblogs.com/baidei/p/14767319.html