代码
// 图片下载
onDownload(filepath, filename) {
const x = new XMLHttpRequest()
x.open('GET', filepath, true)
x.responseType = 'blob'
x.onload = function () {
const blob = x.response
const url = window.URL.createObjectURL(blob)
// 判断是否是IE浏览器
if (window.navigator.msSaveBlob) {
try {
window.navigator.msSaveBlob(blob, filename)
} catch (e) {
}
} else {
const a = document.createElement('a')
a.href = url
a.download = filename
a.click()
}
}
x.send()
},
标签:msSaveBlob,const,标签,filename,window,blob,navigator,下载,图片
From: https://www.cnblogs.com/chunyouqudongwuyuan/p/17198258.html