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

代码如下:

//获取项目名称
function 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;
             }
       }
 },
//在下面函数中通过函数调用,获取项目名称 function 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(项目名称) } }

 

相关文章:

  • 2021-11-17
  • 2021-06-10
  • 2022-12-23
  • 2021-11-28
  • 2021-08-17
  • 2021-06-16
  • 2021-12-24
  • 2021-07-24
猜你喜欢
  • 2022-01-23
  • 2021-06-20
  • 2021-06-19
  • 2021-12-24
  • 2021-11-14
相关资源
相似解决方案