//导出
exportExcel() {
this.axios
.post(
"接口地址",
{
headers: {
"Content-Type": "application/json"//设置请求头,
},
responseType: "blob"//设置responseType
}
)
.then(res => {
const link = document.createElement("a");
const blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
});
link.style.display = "none";
link.href = URL.createObjectURL(blob);
link.setAttribute("download", `统计报表.xls`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
.catch(r => {
console.error(r);
});
},
vue+axios接受后台接口返回的流文件,导出为excel文件,操作方法及乱码问题
最新推荐文章于 2023-11-05 17:41:48 发布