const doDownload = (item) => {
let aUrl = item.address;
let extNameIcon = item.extName;
let extName = item.name;
if (extName.includes(".")) {
extName = extName.split(".")[0];
}
let xml = new XMLHttpRequest();
xml.open("GET", aUrl, true);
xml.responseType = "blob";
xml.onload = () => {
let url = window.URL.createObjectURL(xml.response);
let a = document.createElement("a");
a.href = url;
a.download = `${extName}.${extNameIcon}`;
a.style.display = "none";
a.click();
};
xml.send();
};
标签:xml,文件,对象,extName,item,let,aUrl,下载
From: https://www.cnblogs.com/openmind-ink/p/17502174.html