downloadFile(url, fileName){
//fileurl文件地址(一般是接口返回) filename文件下载后的名字
const x = new XMLHttpRequest()
x.open('GET', url, true)
x.responseType = 'blob'
x.onload = function() {
const url = window.URL.createObjectURL(x.response)
const a = document.createElement('a')
a.href = url
a.download = fileName
a.click()
document.body.removeChild(a);
// 然后移除
}
x.send()
}
版权声明:本文为weixin_41463944原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。