uniapp循环请求接口之后跳转
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) })
本文来自博客园,作者:prince11,转载请注明原文链接:https://www.cnblogs.com/prince11/p/18188863