<a href='文件地址'>下载文件</a>
window.location.href = "文件地址";
window.open("文件地址");
const a = document.createElement('a');
a.href = '文件地址';
a.download = '文件名';
a.click();
const xhr = new XMLHttpRequest();
let url = ''; //接口地址
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function() {
var blob = this.response;
if(blob.type == "text/html"){
return false;
}
if(window.navigator.msSaveOrOpenBlob){ // IE浏览器下
navigator.msSaveBlob(blob, '文件名称');
} else {
var link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = fileName+suffix;
link.click();
window.URL.revokeObjectURL(link.href);
}
};
xhr.send();