请求图片乱码(vue项目)

getvertifyimg().then(res => {

if (res) {

let blob = new Blob([res], { type: "image/jpg" });

let fileName = Date.parse(new Date()) + ".jpg";

if (window.navigator.msSaveOrOpenBlob) {

navigator.msSaveBlob(blob, fileName);

} else {

var link = document.createElement("a");

this.vertifyImg =window.URL.createObjectURL(blob);

}

}

});

封装的请求函数

export function getvertifyimg(data) {

return request({

url: '/clear/check.jpg',

method: 'get',

responseType: 'arraybuffer',

data

})

}

你可能感兴趣的:(请求图片乱码(vue项目))