// 批量上传数据
async mulAdd(){
// this.uniqueArr1(this.arr)
this.noLength1(this.arr)
this.noMax1(this.arr)
// this.noName1(this.arr)
console.log('去除数据库数据',this.arr);
for(let i=0;i<this.arr.length;i++){
const num=i;
let formData = new FormData();
formData.set('file', this.arr[i]);
formData.set('id',this.id)
const length=this.arr.length-1
console.log('num',num);
console.log('length-num',length);
await api.uploadFile(formData).then((res)=>{
if(num===length){
console.log('添加调用的函数XXXX');
this.$parent.fetchData(this.form1)
}
console.log('添加返回的字段',res);
console.log('批量添加成功');
}).catch((err)=>{
})
}
this.handleClose()
},
(39条消息) JS中for循环实现异步方法同步执行调用接口,判断执行完_@必意玲-CSDN博客_js循环调用接口