txt/jpg使用方式:下载
downloadFile(obj) {
if (!obj.filePath) return
const downloadElement = document.createElement('a')
const url = obj.filePath
fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
downloadElement.href = URL.createObjectURL(blob)
downloadElement.download = ''
document.body.appendChild(downloadElement)
downloadElement.click()
})
},
word/xlsx下载
downloadFile(obj) {
if (!obj.filePath) return
const downloadElement = document.createElement('a')
downloadElement.href = obj.filePath
downloadElement.download = obj.fileName
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement)
},
亲测可以~