let url = 'http://127.0.0.1:8080/hhh.json'
let name = url.substring(url.lastIndexOf("/") + 1)
let downLoad = async () => {
let responsePromise = await fetch(url)
let blob = await responsePromise.blob()
let objectURL = window.URL.createObjectURL(blob)
let a = document.createElement('a')
a.href = objectURL
a.download = name
a.click()
a.remove()
}
downLoad()
js通过url地址访问文件做下载,并不是打开文件
最新推荐文章于 2023-07-05 15:07:39 发布