南昌网站免费制作,成都广告投放公司,免费链接生成器,网络规划设计师教程pdf前提是你上传的时候也是切片上传#xff0c;下载的时候后端给你返回的是一个文件id的数组#xff0c;如果是你就可以用下面的方法
// 循环下载文件
// id是每个文件的id type 是一个类型#xff0c;我传入是应为给不同的组件赋值getFile(id, type) {// 通过wen文件id去获取…前提是你上传的时候也是切片上传下载的时候后端给你返回的是一个文件id的数组如果是你就可以用下面的方法
// 循环下载文件
// id是每个文件的id type 是一个类型我传入是应为给不同的组件赋值getFile(id, type) {// 通过wen文件id去获取对应的文件切片的urlsliceFileDownload(id).then((res) {let list []if (res.data.partList) {res.data.partList.map((item) {//自定义请求let instance axios.create({responseType: blob,})instance.get(${item.fileDownloadUrl}).then((info) {list.push(info.data)//判断切片文件是否都获取完毕if (res.data.partCount list.length) {let blob new Blob(list);let link document.createElement(a);link.href window.URL.createObjectURL(blob);let para {fileId: id,fileName: res.data.fileName,location: link.href}// type1 type 2 type 3 type 4 都是我自己的需求图片展示typeother 是文件直接下载if (type 1) {this.addform.coreImageFileList.push(para)} else if (type 2) {this.addform.originalScanImageFileList.push(para)} else if (type 3) {this.addform.refactorDataBodyFile.push(para)} else if (type 4) {this.addform.testReportFile.push(para)} else if (type other) {let name res.data.fileName.slice(res.data.fileName.lastIndexOf(.) 1)link.download res.data.fileNamedocument.body.appendChild(link)link.click()setTimeout(() {window.URL.revokeObjectURL(href)document.body.removeChild(link)}, 0)}}})})}})},// 使用的地方//testReportFile 是一个数组数组中上传了多个文件所以需要循环如果只有一个文件你可以直接把文件id传入就可以。response.data.testReportFile.map((res) {this.getFile(res.fileId, 4)})