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保存返回的流文件