// 附件下载
filesLoad(item) {
console.log(item)
attachDownload({ id: item.id }).then((res) => {
console.log(res)
if (res) {
let blob = new Blob([res.data], { type: ‘application/vnd.ms-excel;charset=utf-8’ })
if (window.navigator.msSaveBlob) {
window, navigator.msSaveBlob(blob, item.name)
} else {
let url = window.URL.createObjectURL(blob)
let link = document.createElement(‘a’)
link.style.display = ‘none’
link.href = url
link.download = item.name
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
} else {
this.$message.error(‘下载失败!’)
}
})
},
在后端没有定义数据的格式的情况下附件下载,定义了数据流的格式请看下一篇文档
最新推荐文章于 2024-04-30 16:57:21 发布