VUE3二进制流下载Excel文件
axios({
url: 'URL',
method:'get',
params:{
'page': 1
},
responseType: "arraybuffer",
}).then(res => {
var blob=new Blob([res.data],{
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8"
});
var contentDisposition =res.headers["content-disposition"];
var patt = new RegExp(
"filename=([^;]+\\.[^\\.;]+);*"
);
var result = patt.exec(contentDisposition);
var filename = result[1];
var downloadElement = document.createElement("a");
var href = window.URL.createObjectURL(blob);
downloadElement.style.display = "none";
downloadElement.href = href;
downloadElement.download = filename;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(href);
})