
原代码:
download(item) {
this.axios.get(api.download+'/'+item.name).then(res => {
// console.log(res)
let bob = new Blob([res.data],{type: 'application/vnd.ms-excel'})
const link = document.createElement('a');
let url = window.URL.createObjectURL(bob);
link.download = '下载文件.xlsx';
link.href = url;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
},
参考文章:javascript下载纯文本、下载Excel,前端解析Excel,下载的Excel无法打开问题解决_前端下载文件流无法打开-CSDN博客
修改:axios请求时需要设置响应类型
download(item) {
this.axios.get(api.download+'/'+item.name,{responseType:"blob"}).then(res => {
// console.log(res)
let bob = new Blob([res.data],{type: 'application/vnd.ms-excel'})
const link = document.createElement('a');
let url = window.URL.createObjectURL(bob);
link.download = '下载文件.xlsx';
link.href = url;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
},













![[Python图像识别] 五十二.水书图像识别 (2)基于机器学习的濒危水书古文字识别研究](https://img-blog.csdnimg.cn/direct/0ae62eb576ad40efabf84a0ac24a3e2c.png#pic_center)





