1. 封装的接口api方法文章来源:https://www.toymoban.com/news/detail-641327.html
exportCoil(responseType:any) {
return REST.request(HTTPMethod.GET, `${this.url}/ExportCoilData`,responseType)
}
2. 组件中调用文章来源地址https://www.toymoban.com/news/detail-641327.html
exportExcel() {
this.coilAPI?.exportCoil('blob').then((res: any) => {
var blob = new Blob([res.data], {
type: "application/x-msdownload;charset=UTF-8"
})
let url = window.URL.createObjectURL(blob)
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.id = 'Adownload'
//命名可能会出现问题,格式一定和后端下载的格式一样
link.setAttribute('download', `铝卷数据_ ${AiDateTime.YMD(new Date())}.xlsx`)
document.body.appendChild(link)
link.click()
})
}
到了这里,关于vue axios 下载excel的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!