支持文件列表可指定下载文件名
This commit is contained in:
@@ -29,7 +29,8 @@ export default {
|
||||
|
||||
fileOps: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
clickDownload: Boolean
|
||||
},
|
||||
|
||||
computed: {
|
||||
@@ -45,7 +46,15 @@ export default {
|
||||
|
||||
methods: {
|
||||
downFile(item) {
|
||||
window.open(`${item.url}`)
|
||||
if (this.clickDownload) {
|
||||
const link = document.createElement('a')
|
||||
link.style.display = 'none'
|
||||
link.href = item.url
|
||||
link.setAttribute('download', item.name)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
} else window.open(`${item.url}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user