request({
url: xxx,
method: ‘post‘,
responseType: ‘blob‘
})
axios.post.then(res => {
let blob = new Blob([res], { type: ‘application/vnd.ms-excel;charset=utf-8‘})
let url = window.URL.createObjectURL(blob)
let alink = document.createElement(‘a‘)
alink.style.display = ‘none‘
alink.href = url
alink.download = ‘xxx.xlsx‘ // 配置下载后的名字和后缀格式
document.body.appendChild(alink)
alink.click()
URL.removeObjectRUL(url)
document.body.removeChild(alink)
})
原文:https://www.cnblogs.com/xk-g/p/14734326.html