vue根據Blob 文件流 保存文件


  fileDownListUrl(this.selectedRowKeys.join(),params).then((res) => {
         console.log(1)
          if (!res) {
          this.$message.warning("文件下載失敗")
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          //一定要知道文件格式
          window.navigator.msSaveBlob(new Blob([res],{type: 'application/x-zip-compressed'}), fileName+'.zip')
        }else{
          let url = window.URL.createObjectURL(new Blob([res],{type: 'application/x-zip-compressed'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName+'.zip')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下載完成移除元素
          window.URL.revokeObjectURL(url); //釋放掉blob對象
        }
        })
        .catch(() => {})

js保存返回的流文件


免責聲明!

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



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