ajax|axios通过get方式下载Excel
vue+element环境下的写法,其它框架也基本一样
【ajax|axios通过get方式下载Excel】主要是将后台返回的数据处理之后下载为.xlsx的文件,再模拟点击下载
axios({
method: "get",
url: "url****",
responseType: "blob",// 重点
headers: {***},
params: params,
})
.then((res) => {
let url = window.URL.createObjectURL(new Blob([res.data]));
let link = document.createElement("a");
link.style.display = "none";
link.href = https://www.it610.com/article/url;
link.setAttribute("download", this.$route.meta.title + ".xlsx");
document.body.appendChild(link);
link.click();
})
.catch(() => {
this.$message.error("网络错误!");
});
推荐阅读
- 2020-04-07vue中Axios的封装和API接口的管理
- gitlab|gitlab 通过备份还原 admin/runner 500 Internal Server Error
- whlie循环和for循环的应用
- 接口|axios接口报错-参数类型错误解决
- 如何通过锻炼的方法治疗前列腺肥大
- JavaScript|vue 基于axios封装request接口请求——request.js文件
- vue.js|vue中使用axios封装成request使用
- 通过复盘快速成长(附模板)
- MyBatis|MyBatis Generator配置
- 运维|如何限制IP 通过 SSH连接服务器