2022-01-19 15:41:12
DownloadFile(fileName) {
var url = "static/http://localhost:8080/static/test.pdf";
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = "blob";
req.onload = function () {
var blob = new Blob([req.response], { type: "application/octetstream" });
var isIE = false || !!document.documentMode;
if (isIE) {
window.navigator.msSaveBlob(blob, fileName);
} else {
var url = window.URL || window.webkitURL;
var link = url.createObjectURL(blob);
var a = document.createElement("a");
a.setAttribute("download", fileName);
a.setAttribute("href", link);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
};
req.send();
}
最后生成于 2023-06-27 21:38:06
热门推荐: