Promise.all([loanproducttype(),getloanproductlist(p)]).then((result) => { this.loading = false; //产品类型 this.producttypes = result[0].jbody.loanProductTypes; console.log(this.producttypes); for(var i= 0;i<this.producttypes.length;i++){ this.productTypeNameKV[this.producttypes[i].productType] = this.producttypes[i].productTypeName; } //表格数据 this.data1 = result[1].jbody.pageInfo.list; this.total1 = result[1].jbody.pageInfo.total; }).catch((error) => { this.loading = false; console.log(error) })
loanproducttype()是请求产品类型 的方法,result[0] 是该接口的返回值。
getloanproductlist(p) 是表格数据的方法,result[1] 是该接口的返回值。
我们遇到什么困难,也不要怕,微笑着面对Ta,消除恐惧的最好办法就是面对恐惧,加油奥利给!!!
js ES6 Promise.all 等两个接口都返回成功执行
原文:https://www.cnblogs.com/lq2333/p/12172125.html