标签:fun 文件下载 evo rem object The cli file body
// 点击文件下载,fileUrl为http的url
function downloadFile(fileUrl) {
fetch(fileUrl).then(res => res.blob()).then(blob => {
const a = document.createElement(‘a‘)
document.body.appendChild(a)
a.style.display = ‘none‘
const url = window.URL.createObjectURL(blob)
a.href = url
a.download = fileUrl
a.click()
document.body.removeChild(a)
window.URL.revokeObjectURL(url)
})
}
标签:fun 文件下载 evo rem object The cli file body
原文地址:https://www.cnblogs.com/jone-chen/p/14578307.html