前面不写略过,在headers 里面配置
直接上代码
headers: {
'Content-Type': 'application/json; application/octet-stream'
},
responseType: 'arraybuffer',
}).then(res => {
let b = new Blob([res.data], { type: 'application/vnd.ms-excel' });
let url = URL.createObjectURL(b);
let link = document.createElement('a');
link.download = '名字’.xlsx';
link.href = url;
link.click();
})