<p @click="handleDoc(0)">xxx</p>
<p @click="handleDoc(1)">xxx</p>
<p @click="handleDoc(2)">xxx</p>
docObj: {
0: 'https://xxx/xxx/xxx/xxx/xxx.doc',
1: 'https://xxx/xxx/xxx/xxx/xxx.pdf',
2: 'https://xxx/xxx/xxx/xxx/xxx.pdf',
},
handleDoc (type) {
var Url = this.docObj[type]
if(type == 0) {
window.open(Url)
} else {
var list = Url.split('/')
const a = document.createElement('a')
fetch(Url).then(res => res.blob()).then(blob => {
a.href = URL.createObjectURL(blob)
a.download = list[list.length -1] || ''
document.body.appendChild(a)
a.click()
})
}
},