vue axios下载接口返回的zip包文件流。

downAllZip({
        type: this.type,
        page: this.pageNo,
        size: this.pageSize,
        start: this.starttime,
        end: this.endtime,
        t: new Date().getTime()
      }).then((res) => {
        const blob = new Blob([res], { type: 'application/zip' }) // new一个二进制对象
        const url = window.URL.createObjectURL(blob) // 转化为url
        const link = document.createElement('a') // 创建个a标签
        link.href = url
        link.download = '证书包' + (new Date()).getTime()// 重命名
        link.click()
        URL.revokeObjectURL(url)
      }).catch(function(err) {
        console.log(err)
      })
options = {
              url,
              method: 'POST',
              headers: { 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8' },
              responseType: 'blob',
              data: qs.stringify(params)
            }

  

 

posted @ 2021-06-29 17:41  秋风2016  阅读(1256)  评论(0编辑  收藏  举报