想循环上传每个文件,循环第一次时isrepeat参数为true,拿到第一次循环上传成功后台返回的路径,作为往下循环的pathList,并且往下循环isrepeat参数为false,思路有点凌乱乱...
upload(data,action) {
let formData = new FormData()
data.forEach((item) => {
formData.append('fileList', item)
if (data.length === 1 || action === 'fileUpload') {
//单文件
formData.append('pathList', item.name)
} else {
formData.append('pathList', item.webkitRelativePath)
}
formData.append('pid', this.currentNodeKey)
formData.append('isrepeat', true)
this.$myHttp({
method: 'post',
url: this.prefix + '/doc/docDir/uploadHtml2Public',
data: formData,
headers: { 'Authorization': 'Sys ' + sessionStorage.getItem('token'), 'showLoading': 'true' }
}).then((res) => {
this.refreshTree()
}).catch((error) => {
console.log(error)
})
})
}
代码没看明白,不过感觉本质上是一个根据当前请求的响应决定下次如何请求的问题,你看看下面的实例代码有帮助不