this.$http.get(`/api/user/getVerificationCode?userAccount=${this.username}`,{
responseType: "arraybuffer",
}).then(rsp => {
if (rsp.data) {
let img = btoa(
new Uint8Array(rsp.data).reduce((data, byte) => data + String.fromCharCode(byte), '')
);
this.verifyImg = 'data:image/png;base64,' +img;
}
})
在请求的时候,需要声明接收的数据是arraybuffer类型
然后将从后台获取的图片流进行转换