downloadFile(path, name) {
fetch(path).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
let node = document.createElement('a')
node.href = URL.createObjectURL(blob)
node.download = name;
document.body.appendChild(node)
node.click()
})
}
前端根据url下载文件、各种格式图片以及txt文件
最新推荐文章于 2024-04-28 13:46:58 发布