$.ajax({
type: 'post',
url: "",
xhrFields: { responseType: "blob" }, // 主要是这一句
data: {},
success: function(data) {
that.download(data,'自己起的名字.xlsx')
}
})
},
download(data, fileName) {
if (!data) {
return
}
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a');
link.style.display = 'none';
link.href = url;
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
}