根据appId匹配项目名称

有时候后端返回的接口中也许没有我们想要的字段,可以通过下面的方式拿到想要的字段

代码如下:

//获取项目名称
getBizName(appId) {
       let proNameList = this.$store.state.mobileIndex.bizList;  //包含appId和appName两个字段
       for (var index in proNameList) {
             var bizItem = proNameList[index];
             if (bizItem.appId === appId) {
                  return bizItem.name;
             }
       }
 },
//在下面函数中通过函数调用,获取项目名称 qureBizList(appid) { let InfoList = []; InfoList = this.$store.state.mobileIndex.userInfoList;  //只有appId字段,没有appName字段 for(var i =0;i<InfoList.length;i++){ var userItem = InfoList[i].appId; InfoList[i].appName = this.getBizName(userItem);  //获取appId对应的appName(项目名称) } }

猜你喜欢

转载自www.cnblogs.com/minjh/p/9023247.html