// 把文件流下载下来
const downloadMethods = (name, res) => {
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = name // 文件名
document.body.appendChild(link)
link.click()
window.setTimeout(function() {
URL.revokeObjectURL(blob)
document.body.removeChild(link)
}, 0)
}
前端通过后端返回文件流下载文件
最新推荐文章于 2024-06-13 10:06:49 发布