// 这是一个接口请求,要求返回responseType是blob格式
this.$api.xxx(parameters, 'blob').then(res => {
tableExport(res, name)
})
// 导出流格式的处理
export const tableExport = (res, fileName) => {
const link = document.createElement('a')
let blob = new Blob([res], { type: 'application/vnd.ms-excel' })
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
link.setAttribute('download', fileName + '.xlsx')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
前端普通文件导出处理
最新推荐文章于 2023-05-17 11:51:16 发布