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