vue通过地址下载文件
前言通过a标签// 创建a标签const link = document.createElement('a')// download属性link.setAttribute('download', row.newName)// href链接link.setAttribute('href', row.downloadPath)// 自执行点击事件link.click()do...
·
前言
通过地址下载图片看这篇:https://blog.csdn.net/s1441101265/article/details/103307876
后台返回文件流
看到有说不行的,我又看了下代码,是这样的。
后台返回文件流,然后设置response
前端只需要这样写就行了。
如果按照这样写还不能下载的话,那应该是后端问题了(ps:我就是后端)
示例
请求
返回
示例
- 通过a标签
// 创建a标签
const link = document.createElement('a')
// download属性
link.setAttribute('download', row.newName)
// href链接
link.setAttribute('href', row.downloadPath)
// 自执行点击事件
link.click()
document.body.removeChild(link)
- 通过open
window.open(row.downloadPath)
更多推荐
已为社区贡献17条内容
所有评论(0)