handleExport () {
this.$http.post(url,params,{type: 'json',responseType:'blob' }).then(res => {
const blob = new Blob([res], { type: 'application/x-download' });
const fileName = "文件名.xlsx";
const elink = document.createElement("a");
elink.download = fileName;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
}).catch(() => {
})
},
注意要添加 responseType:'blob'