getBlob(url).then((blob: any) => {
saveAs(blob, '附件文件.xlsx')
})
const getBlob = (url: string) => {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.responseType = 'blob'
xhr.onload = () => {
if (xhr.status === 200) {
resolve(xhr.response)
}
}
xhr.send()
})
}
const saveAs = (blob: any, filename: string) => {
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = filename
link.click()
}