此段代码只能兼容IE10以上Blob处理,IE10以下不兼容哦
const fileName = 'xxxx.xls'
const blob = new Blob([response.data])
//兼容ie处理 for IE10+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveBlob(blob, fileName)
} else {
// for firefox,chrome,ETC 模拟a链接下载
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
URL.revokeObjectURL(link.href)
document.body.removeChild(link)
}
如需转载请标注地址