if (this.model.caseWorkPartyModelList.length > 0) { let promises = []; // 用于存储所有异步操作的Promise let that = this this.model.caseWorkPartyModelList.forEach(async (item, index) => { if (item.idCard.indexOf('*') !== -1) { let params = { id:this.model.caseWorkPartyModelList[index].id } // 将每个异步调用放入promises数组 promises.push( new Promise(async (resolve) => { let res1 = await queryIdCardByTel(params); console.log('res1res1', res1); if (res1.error_code == '200') { that.model.caseWorkPartyModelList[index].idCard = res1 .data.idCard; } resolve(); // 异步操作完成后resolve这个Promise }) ); } }) await Promise.all(promises); } uni.navigateTo({ url: '/casemodel/pages/case-mediate/mediate-fail/mediate-fail?type=' + JSON.stringify(this.model) })
标签:uniapp,promises,res1,接口,let,caseWorkPartyModelList,跳转,Promise,model From: https://www.cnblogs.com/prince11/p/18188863