前端zip包下载

downLoad (rows) {
      if (rows) {
        let params = {
          id: rows.id,
          fileNames: rows.docPath,
          type: 'doc'
        }
        downLoadFileZip(params).then(resp => {
          let blob = new Blob([resp.data], {type: 'application/zip'})
          if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            window.navigator.msSaveOrOpenBlob(blob, `${rows.title}.zip`)
          } else {
            let url = window.URL.createObjectURL(blob)
            const link = document.createElement('a') // 创建a标签
            link.href = url
            link.download = `${rows.title}.zip` // 重命名文件
            link.click()
            URL.revokeObjectURL(url) // 释放内存
          }
        })
      }
    }

 

posted @ 2021-09-17 16:23  一两米  阅读(310)  评论(0编辑  收藏  举报