后端返回流文件的时候的处理:
axios.get(url, {
...config,
headers: { platform: 'pc' },
params,
responseType: 'blob',
});
getFailData({ uuid })
.then((res) => {
const content = res;
const blob = new Blob([content]);
const fileName = '失败数据.xlsx';
if ('download' in document.createElement('a')) {
const elink = document.createElement('a');
elink.download = fileName;
elink.style.display = 'none';
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
} else {
navigator.msSaveBlob(blob, fileName);
}
})
.catch((err) => {
console.log(err);
});
};