api写法
import http from '@/utils/request'
export function exportData(params) {
return http({
url: '/customs/reimburse/export',
method: 'post',
params,
responseType: 'arraybuffer',
})
}
解析处理
let res = await exportData({ ids: 5 })
let href = window.URL.createObjectURL(new Blob([res],
{ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }))
const downloadElement = document.createElement('a')
downloadElement.href = href
downloadElement.download = '导出报表.xlsx'
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)