// 下载附件文件
const downLoad = (item: any) => {
const a = document.createElement("a")
// fetch方法提供了一种更简单和灵活的方式来进行HTTP请求,并返回一个Promise对象,以便处理响应数据。
fetch(item.url) // 下载的链接
.then((res) => res.blob())
.then((blob) => {
// 将链接地址字符内容转变成blob地址
a.href = URL.createObjectURL(blob)
a.download = item.name // 下载文件的名字
document.body.appendChild(a)
a.click()
})
};
简单,就这么实现