request
.post("xxxx", param, {
responseType: "blob" //设置响应的数据类型为一个包含二进制数据的 Blob 对象,必须设置!!!
})
.then(res => {
let blob = res.data;
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, "xxx.xls");
} else {
let url = window.URL.createObjectURL(blob);
const aLink = document.createElement("a");
aLink.href = url;
aLink.download = "xxx.xls";
document.body.appendChild(aLink);
aLink.click();
document.body.removeChild(aLink);
window.URL.revokeObjectURL(url);
}
});