axios.post(url,data,{responseType:'blob'}).then(res => {
const blob = new Blob([res.data]);//处理文档流
const fileName = '资产列表.xlsx';
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); // 释放URL 对象
document.body.removeChild(elink);
})
给axios请求设置{responseType:'blob'}
就可以接收文件流了