乐趣区

关于javascript:下载图片-不预览

down () {

  let request = new XMLHttpRequest()
  request.responseType = 'blob'
  // 传入文件链接
  // request.open('GET', this.tokenData.serverUrl + item.path)
  request.open('GET', 'https://img1.baidu.com/it/u=467403473,3088799256&fm=26&fmt=auto')
  request.onload = function () {let url = window.URL.createObjectURL(this.response)
    let a = document.createElement('a')
    document.body.appendChild(a)
    a.href = url
    a.download = '图片'
    a.click()}
  request.send()

}

退出移动版