/*
下载表格
*/
export const downloadFile = (url, fileName = '表格.xlsx') => {
axios({
url: url,
headers: {
// Authorization: getToken(),
},
responseType: 'blob',
}).then(res => {
const content = res
const blob = new Blob([content])
if ('download' in document.createElement('a')) { // 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href) // 释放URL 对象
document.body.removeChild(elink)
} else { // IE10+下载
navigator.msSaveBlob(blob, fileName)
}
})
}
js 表格下载
最新推荐文章于 2024-06-22 08:17:10 发布