首先看下我們接收到的請求:
特別注意: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亂碼