1. 后端返回文件 url 时
const link = document.createElement('a') // 创建一个 a 标签用来模拟点击事件
link.style.display = 'none'
link.href = '文件url'
link.setAttribute('download', '文件名')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
2. 后台返回文件流时,用 blob 对象下载文件
// res 是返回的文件流,type 是文件MIME类型, fileName 是给下载的文件一个名称
const blobDownloadFile = (res: any, type: string, fileName