import axios from 'axios'
function Excels(data, filename) {
const link = document.createElement('a')
let blob = new Blob([data], {type: 'application/vnd.ms-excel;charset=utf-8'})
let objectUrl = URL.createObjectURL(blob)
link.href = objectUrl
link.download = filename
link.click()
// 兼容IE11下载
if ("msSaveOrOpenBlob" in navigator) {
window.navigator.msSaveOrOpenBlob(blob, filename + '.xls');
} else {
// 谷歌或其他浏览器下载
URL.revokeObjectURL(objectUrl);
}
}
function Excel(urls, Name = new Date().getTime()) {
let url = urls
axios.get(url, {
responseType: 'blob',
}).then(res => {
console.log(res)
Excels(res.data, Name)
})
}
export default {
Excel
}
导出excel
最新推荐文章于 2023-09-05 10:52:04 发布