let res = await getTemplateExcel("参数")
console.log(res);
let blob=new Blob([res.data],{type:"application/vnd.ms-excel"})
let URL=window.URL.createObjectURL(blob)
window.open(URL)
上面这种方式通过window.open的方式下载的话无法重命名,并且下载出来的文件为路径最后一串为文件名
let res = await getTemplateExcel("参数")
const xlsx="application/vnd.ms-excel"
const blob=new Blob([res.data],{type:xlsx})
let fileName="表单列表"+new Date().getTime()+".xlsx"
let a=document.createElement("a")
a.download=fileName
a.href=window.URL.createObjectURL(blob)
a.click()
a.remove()
这种方式可以给文件重命名。
export const getTemplateExcel = (params) => {
return service({
url: `/web/cooPartnerAdmin/excel/getTemplate`,
method: 'get',
params,
responseType:'blob'//注意要配置这一项
})
}