打印出后端返回的数据:乱码了

解决方法:
在前端请求的时候携带请求头responseType:blob,
axios({
method: 'GET',
url: '/api',
params: params,
responseType: 'blob'
}).then(res=>{
console.log(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)
})
携带请求头后,再次打印后端返回的数据,data为Blob对象了,

👍【注意】:
axios使用封装过后的请求设置请求头responseType:'blob'不生效,推荐大家使用axios({})的方式,不要使用如:axios.get()的方式