标题 vue后台管理系统下载excel表格
1.调用后台接口传入三个参数,url,data参数,第三个参数为一个对象,表格下载返回类型。
2.创建 Blob实列传入后台返回的数据和以对象形式声明类型参数。
3.获取数据后调用window.URL。createObjectURL方法。传入blob实列对象。
4.接着生成url地址
5.定义url变量接收
6.创建一个a标签
7.把url赋值给a标签的href属性
8.调用a标签的setAttribute方法传入两个参数
9.第一个参数为download第二个参数是下载时表格的名称
10.把a标签放到body里
11.调用a标签的click方法`
const vm = this
const params ={
createTimeStart: vm.searchForm.startTime,
createTimeEnd: vm.searchForm.endTime,
}
vm.$axios.post('/match-admin/tax/getTaxFileExcel',params, {
responseType: 'blob'})
.then((response) => {
console.log("response==",response)
const url = window.URL.createObjectURL(new Blob([response.data],{
type: