原因:在数组循环中调用方法,第一次循环,调用方法,方法没走完,就会再次循环,所以需要使用async await
this.infoForm.acadList.map(async (r) => {
let recordId =
this.infoForm.picUploadTime +
this.hoursInfoId +
this.infoForm.idNumber;
await this.getFiles(
this.$constant.FILE_TYPE.INFO_ACADEMIC_TITLE,
recordId + r.no,
"Acad",
r.no
);
});
async getFiles(typeId, recordId, type, no) {
await PersonalCenterApi.getClass()
.getFiles(typeId, recordId)
.then((res) => {
this.infoForm.acadList.forEach((r, index) => {
if (r.no == no) {
this.$set(
this.infoForm.acadList[index],
"imgAcad",
res.data.data
);
}
});
}
})
.catch((err) => {});
},
网友评论