比如我有个文件url的列表urlFiles = ['a','b','c'],当我想下载这三个文件的时候,我使用了下面的代码,但是每次下载只有a下载成功
urlFiles.forEach(item => {
fetch(item).then(res => res.blob()).then(blob => {
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
//测试链接console.log(a.href)
a.download = 'fileName' // 下载文件的名字
document.body.appendChild(a)
a.click()
})
}
自己找到了
参考:https://juejin.cn/post/691936...