前端下载文件
export function downloadFile(data, fileName){
const a = document.createElement('a') let href = window.URL.createObjectURL(new Blob(["\ufeff", data], { type: 'text/csv;charset=utf-8;' })) a.href = href a.download = decodeURIComponent(fileName) document.body.appendChild(a) a.click() document.body.removeChild(a) window.URL.revokeObjectURL(href) }
downloadSpuAnalysisReportNew()
.then(response => {
let data = response.data
let headers = response.headers
let fileName = filenameRegex(headers)
downloadFile(data, fileName)
}).catch(error => {
console.log(`donwload error: ${error}`)
})