'content-type': 'application/json',
responseType: 'arraybuffer',
const arrayBuffer = new Uint8Array(res.data) //将二进制数据保存为arrayBuffer格式
this.imgCode = uni.arrayBufferToBase64(arrayBuffer) //'data:image/png;base64,'+拼接前缀
实现代码如下:
'content-type': 'application/json',
responseType: 'arraybuffer',
const arrayBuffer = new Uint8Array(res.data) //将二进制数据保存为arrayBuffer格式
this.imgCode = uni.arrayBufferToBase64(arrayBuffer) //'data:image/png;base64,'+拼接前缀
实现代码如下: