本地下载
1.把文件放在public文件夹下
2.把a标签写在了方法里,href后是文件的路径(注意!!“process.env.BASE_URL”代表public)
// 下载模板
getDownload() {
const anchor = document.createElement('a')
anchor.href = `${process.env.BASE_URL}queModel.xlsx`
anchor.setAttribute('download', '试题模板.xlsx')
anchor.innerHTML = 'downloading...'
anchor.style.display = 'none'
document.body.appendChild(anchor)
setTimeout(() => {
anchor.click()
document.body.removeChild(anchor)
setTimeout(() => { self.URL.revokeObjectURL(anchor.href) }, 250)
}, 66)
},
转载:https://blog.csdn.net/weixin_45891332/article/details/120033170