批量下载附件
<el-button type="primary" @click="downLoadFileList(scope.row)">下载</el-button>
// 下载附件
downLoadFileList(record) {
const jsonUrlList = record.fileUrlList
// 循环遍历调用downloadFile方法
for (let i = 0; i < jsonUrlList.length; i++) {
const url = jsonUrlList[i]
const name = url.substring(url.lastIndexOf('/') + 1, url.length)
this.downloadFile(url, name)
}
},
// 批量下载
downloadFile(url, name) {
const download = async() => {
const response = await fetch(url) // 内容转变成blob地址
const blob = await response.blob() // 创建隐藏的可下载链接
const objectUrl = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = objectUrl
a.download = name
a.click()
a.remove()
}
download()
},