vue 下载文件流

 , kalman_btn() {
      var that = this;
      that.axios({
        method: 'post',
        url: 'kalman/export',
        data: {
          token: http.getToken()
        },
        responseType: 'blob'
      }).then(response => {
        console.log(response)
        that.download(response)
      }).catch((error) => {

      })
    }
//方法 
    , download (data) {
      if (!data) {
          return
      }
      let url = window.URL.createObjectURL(new Blob([data]))
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.setAttribute('download', 'excel.xlsx')

      document.body.appendChild(link)
      link.click()
  }

你可能感兴趣的:(老年健忘症笔记)