前端涉及到导出文件时可以使用Blob进行下载
这里是用的vue
this.$store.dispatch('exportList').then((response) => {
var blob = new Blob([response], {type: 'application/vnd.ms-excel'})
var downloadElement = document.createElement('a')
var href = window.URL.createObjectURL(blob) // 创建下载的链接
downloadElement.href = href
document.body.appendChild(downloadElement)
downloadElement.click() // 点击下载
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch(() => {
})
`
请求接口时一定要用download方式
export function exportList() { return http.download('/order/appeal/export')}