图片批量下载

let imgUrl = [
  "https://i.ytdcloud.com/288110849371930624/fa20782866b64c1cb93d9bf9985f1a53.png",
  "https://i.ytdcloud.com/288110849371930624/e9d4bd26d3014d299f6f374106eaf615.png",
  ]
imgUrl.forEach((item,index)=>{
      setTimeout(()=>{
      axios({
        url: item, //URL,根据实际情况来
        method: "get",
        responseType: "blob"
      }).then(function (response) {
        var a = document.createElement('a')
              document.body.appendChild(a)
              a.style = 'display: none'
              let blob = new Blob([response.data], { type: response.data.type });
              var url = window.URL.createObjectURL(blob)
              console.log(url)
              a.href = url
              a.download = item.split('/')[4]
              a.click()
              a.remove()
              window.URL.revokeObjectURL(url)
      });
    },index*200)
})

你可能感兴趣的:(图片批量下载)