首先看下我们接收到的请求:
特别注意:responseType: 'blob'
axios({
method: 'GET',
url: '/api',
params: params,
responseType: 'blob'
}).then(res=>{
let blob = new Blob([res.data], {type: "application/vnd.ms-excel"});
let url = window.URL.createObjectURL(blob);
window.location.href = url;
}).catch(err=>{
console.log(err)
})
参考:vue axios 请求二进制流excel文件,response乱码
vue + axios 通过blob 转换excel文件流 下载乱码问题
vue2.x 下载后台传过来的流文件(excel)后乱码问题(转载)
————————————————
版权声明:本文为CSDN博主「兰亭古墨」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/hefeng6500/article/details/82988624