前端-请求获取图片流下载图片、展示图片
请求时要设置responseType为"arraybuffer";httpService.accessAPI({apiObj:apiUrl.getQrCodePicture,responseType:"arraybuffer",query:{qrCodeName:this.chooseItems[0]..
·
- 请求时要设置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="">
更多推荐
已为社区贡献6条内容
所有评论(0)