返回文件流
downloadFunc('名称.后缀',res)
function downloadFunc(fileName, data) {
const blob = new Blob([data], { type: `'application/vnd.ms-excel';charset=utf-8` })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
downloadElement.href = href
downloadElement.download = fileName
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
window.URL.revokeObjectURL(href)
}
export function spaceExplodReport(data) {
return request({
url: '',
method: 'post',
data,
responseType: 'blob'. //接口中必传 !!!!!!!!!!!!!ResponseType它允许我们手动的设置返回数据的类型
})
}
后段返回文件流下载本地
于 2024-03-06 10:03:13 首次发布