- 请求时要设置responseType为"arraybuffer";
httpService.accessAPI({
apiObj:apiUrl.getQrCodePicture,
responseType:"arraybuffer",
query:{
qrCodeName:this.chooseItems[0].id,
},
}).then(result => {
this.srcImg='data:image/jpg;base64,'+ btoa(new Uint8Array(result).reduce((data, byte) => data + String.fromCharCode(byte), ''));
let link = document.createElement('a');
link.href = this.srcImg;
link.download = "qrCode.jpg";
link.click();
})
<img :src = "srcImg" alt="">