从两部分解决,一个是从axios上做配置修改:
export function exportList(params: any) {
return request.post('/advise/export', params, {
responseType: 'blob'//添加这个返回类型配置
})
}
其次是下载导出的链接配置:
await exportDetailList(req).then((res: any) => {
const blob = new Blob([res?.data], { type: 'application/vnd.ms-excel' })
const _fileName = res?.headers['content-disposition'].split(';')[1].split('=')[1]
const link = document.createElement('a')
link.style.display = 'none'
// @ts-ignore
const url = window.URL || window.webkitURL || window?.moxURL
link.href = url.createObjectURL(blob)
link.download = decodeURIComponent(_fileName)
link.click()
url.revokeObjectURL(link.href)
})