实现前端调用接口拿到值,把值作为参数传入当前接口(异步和同步之间的先后顺序)

1.监听列表数据

 "copyForm.childSaveVoList": {
                handler: async function () {
                    if (!this.queryProp.id) {
                        let that = this;
                        let preNumList = [];
                        const list = this.copyForm.childSaveVoList || [];
                        for (let i = 0; i < list.length; i++) {
                            const num = await that.getChildNum(preNumList);
                            // list[i].birthCretificateNum = num;
                            preNumList.push(num);
                            that.cretificateNumList = preNumList;
                            that.$forceUpdate();
                        }
                    }
                }
            },

2.调用接口,将拿到的值作为参数接着调用

  /*获取最小出生证编号*/
            getChildNum(list) {
                let that = this;
                return new Promise(resolve => {
                    that.loading = true;
                    let params = {
                        affiliationType: that.queryProp.affiliationType,
                        cretificateNumList: list,
                    };
                    getAvailableAndLeastBirthCretificateNum(params).then(res => {
                        resolve(res);
                    }).finally(() => {
                        that.loading = false;
                    });
                })
            },
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容