下载二进制文件

2019-09-29  本文已影响0人  Thomas赵骐
  this.$http
    .post(URL, qs.stringify(data), {
      responseType: 'blob'
    })
    .then(res => {
      let blob = new Blob([res.data], {
        type:
          'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
      })
      let downloadElement = document.createElement('a')
      let href = window.URL.createObjectURL(blob)
      downloadElement.href = href
      downloadElement.download = scope.row.project_number
      document.body.appendChild(downloadElement)
      downloadElement.click()
      document.body.removeChild(downloadElement)
      window.URL.revokeObjectURL(href)
    })
上一篇 下一篇

猜你喜欢

热点阅读