简单的下载链接,直接跳转即可,如果需要在header里面加token ,如下。
var xhr = new XMLHttpRequest();
xhr.open("GET",url);
xhr.responseType = "blob";
xhr.setRequestHeader("token",token);
xhr.onload = function(){
if (this.status === 200) {
var blob = this.response;
var a = document.createElement('a');
a.download = 'fileName.xlsx';
a.href = window.URL.createObjectURL(blob);
a.click();
}
}
xhr.send();