首页 > 技术文章 > post文件下载

baryon 2018-08-16 22:52 原文

 this.$http({
          method: 'post',
          url: '/file/download',
          responseType: 'blob',
          data: JSON.stringify(this.theDocument)
        }).then(response => {
          let headers = response.headers
          let _blob = new Blob([response.data], {
            type: headers['Content-Type']
          })
          let _link = document.createElement('a')
          _link.href = window.URL.createObjectURL(_blob)
          _link.download = this.theDocument.thename
          _link.click()
        })

推荐阅读