通过接口获取到表格内容
const content = r.data;
const blob = new Blob([ content ]);
let filename=‘’;
if (!filename) {
let disposition = r.headers[“content-disposition”];
if (disposition) {
let respcds = disposition.split(“;”);
for (let i = 0; i < respcds.length; i++) {
let header = respcds[i];
if (header !== null && header !== “”) {
let headerValue = header.split(“=”);
if (headerValue !== null && headerValue.length > 0) {
if (headerValue[0].toLowerCase() === “filename”) {
filename = decodeURI(headerValue[1]);
break;
}
}
}
}
}
}
if (‘download’ in document.createElement(‘a’)) {
const elink = document.createElement(‘a’);
elink.download = filename;
elink.style.display = ‘none’;
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
} else {
navigator.msSaveBlob(blob, filename);
}
08-11
1483
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)