Bootstrap

前端图片下载到本地

function downloadImg(url,name){
  fetch(url)
      .then(res=>{
        res.blob().then(blob=>{
          let a=document.createElement('a');
          let url=window.URL.createObjectURL(blob);
          let filename=name|| '图片.jpg'
          a.href=url;
          a.download=filename
          a.click()
          window.URL.revokeObjectURL(url);
        })
      })
   }

;