首页 > 其他分享 >下载fetch

下载fetch

时间:2022-12-10 10:45:34浏览次数:34  
标签:body const url blob document fetch 下载

fetch(url).then(res => res.blob()).then(blob => {
  const a = document.createElement('a')
  document.body.appendChild(a)
  a.style.display = 'none'
  const url = window.URL.createObjectURL(blob)
  a.href = url
  a.download = ''
  a.click()
  document.body.removeChild(a)
  window.URL.revokeObjectURL(url)
})

  

标签:body,const,url,blob,document,fetch,下载
From: https://www.cnblogs.com/newBugs/p/16970914.html

相关文章