vue处理文件流 点击下载文件
2021-03-02 本文已影响0人
吃肉肉不吃肉肉
download(item){
this.name=item.class
var that =this
apis.GetFiles({id:item.id}).then(res => {
that.downloadGO(res)
}).catch(() => {
})
},
downloadGO (data) {
if (!data) {
return
}
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', this.name)
document.body.appendChild(link)
link.click()