a标签文件下载
downloadFile(url, filename) {
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
const url = window.URL.createObjectURL(xhr.response);
const aDom = document.createElement('a');
aDom.style.display = 'none';
aDom.target = '_blank';
aDom.href = url;
aDom.download = fileName;
document.body.appendChild(aDom);
aDom.click();
setTimeout(() => {
document.body.removeChild(aDom);
}, 300);
}
xhr.send();
}