axios[method](url, data, {
responseType: 'blob' // blob arraybuffer
}).then(res => {
let blob = new Blob([res.data],{type: 'application/vnd.ms-excel'});
if (!!window.ActiveXObject || "ActiveXObject" in window) {
window.navigator.msSaveOrOpenBlob(blob, 'fileName');
} else {
const link = document.createElement('a');
link.style.display = 'none';
link.href = URL.createObjectURL(blob);
link.setAttribute('download', 'fileName');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
resolve(res);
}).catch(err => {
reject(err);
})
js使用blob导出excel,兼容IE
最新推荐文章于 2024-05-17 15:13:55 发布