下载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)
})

  

posted @ 2022-12-10 10:38  小万子呀  阅读(19)  评论(0编辑  收藏  举报