后端返回了excel文件,前端利用a标签下载
const blob = new Blob([data],{type:'application/vnd.ms-excel'})
const a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = 'download'
a.click()
URL.revokeObjectUrl(a.href)
该代码谷歌可以下载,为什么在火狐上没反应?也没有报错,但是无法下载,求解
不要生成a标记,预先写一个a标记,隐藏,然后在这里改它的href和download属性即可,
`const blob = new Blob([data],{type:'application/vnd.ms-excel'})
const a = document.getElementById('a_id')
a.href = URL.createObjectURL(blob)
a.download = 'download'
a.click()
URL.revokeObjectUrl(a.href)`