// 通过文件流下载
static downloadFile (data, fileName) {
const a = document.createElement('a')
document.body.appendChild(a)
a.style = 'display: none'
const blob = new Blob([data], {
type: 'application/octet-stream'
})
const url = window.URL.createObjectURL(blob)
a.href = url
a.download = fileName
a.click()
window.URL.revokeObjectURL(url)
}
// 通过url进行下载
static downloadUrlFile (url, fileName) {
const a = document.createElement('a')
document.body.appendChild(a)
a.style = 'display: none'
a.href = url
a.download = fileName
a.click()
window.URL.revokeObjectURL(url)
}
网友评论