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)
            }

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM