首页 > 其他分享 >将嵌套的对象合并到一个对象里面,删除键名、属性名的空格

将嵌套的对象合并到一个对象里面,删除键名、属性名的空格

时间:2023-01-11 16:57:56浏览次数:31  
标签:tmp info 键名 对象 detail number 嵌套 result userNo

先看一下要处理的数据

当一个我们拿到这样的数据是不是很头痛,接下来处理数据

created(){
           let result = [];
           for(let i in this.info){
               let tmp = {
                   balance:this.info[i].balance,
                   realName:this.info[i].realName||'',
                   countryCode: this.info[i].countryCode,
                   name:this.info[i].name,
                   idType:this.info[i].idType,
                   idCard:this.info[i].idCard,
               };

               if(this.info[i].detail){
                   tmp.number=this.info[i].detail.Number.split('/')
                   tmp.userNo=tmp.number[1]||i
                   tmp.ServiceStatus = this.info[i].detail['Service Status']=="正常"?'Y':'N';
                   tmp.ActivationTime = this.info[i].detail['Activation Time']||'';
                   tmp.Validity = this.info[i].detail['Validity']||'';
                   tmp.ActivationExpiry = this.info[i].detail['Activation Expiry']||'';
               }else{
                   tmp.number=['+'+i];
                   tmp.userNo=i;
               }
               tmp.userNo=tmp.userNo.replace('+','')
               result.push(tmp);
           }
           console.log(result)
               
},

效果图

 

标签:tmp,info,键名,对象,detail,number,嵌套,result,userNo
From: https://www.cnblogs.com/srqsl/p/17044232.html

相关文章