arrayBufferToBase64(buffer) {
var binary = ''
var bytes = new Uint8Array(buffer)
var len = bytes.byteLength
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i])
}
return window.btoa(binary)
},
"data:image/jpeg;base64," + this.arrayBufferToBase64('返回数据')
注意:在请求后台接口时,要设置responseType类型为: arraybuffer
二进制文件流转base64
最新推荐文章于 2024-07-21 23:54:33 发布