
后端返回文件流,下载的文件无法读取,损坏,原因是因为接口处理没有加 blob类型

downloadFile(row.fileId).then(res => {
// res 即后端返回的数据流
const blob = new Blob([res.data])
if (blob && blob.size === 0) {
this.$notify.error('内容为空,无法下载')
return
}
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = row.fileName
document.body.appendChild(link)
link.click()
window.setTimeout(() => {
window.URL.revokeObjectURL(blob)
document.body.removeChild(link)
}, 0)
this.$message.success('下载成功')
})