this.getYearExport(this.exportSearch).then((res) => {
this.loading = false
const fileName = res.headers['content-disposition'].split('=')[1]
const _res = res.data
const blob = new Blob([_res], { type: 'application/xls' })
if ('download' in document.createElement('a')) {
const downloadElement = document.createElement('a')
// 创建下载的链接
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
// 下载后文件名
// downloadElement.download = fileName.replace('_', '')
downloadElement.download = '年度计划.xls'
document.body.appendChild(downloadElement)
// 点击下载
downloadElement.click()
// 下载完成移除元素
document.body.removeChild(downloadElement)
// 释放掉blob对象
window.URL.revokeObjectURL(href)
} else {
navigator.msSaveBlob(blob, fileName)
}
})
如图为写死为了年度计划