蔚蓝的萧瑟
贫民
贫民
  • 最后登录2021-09-29
  • 发帖数2
阅读:4200回复:0

[vue]VUE获取后端多层嵌套JSON数据解析

楼主#
更多 发布于:2021-09-28 19:42




前段时间写了一个VUE多层嵌套的JSON数据对象,现在记录一下





//
显示 display:function()
{ console.log(this.$store.state.userInfo)
this.$axios.get("api/remu/querySubmissionReview",
        { params:{ page:1, userAction:this.zhuangtai, userId:this.$store.state.userInfo.id, username:'', phone:'', email:'' }
        }).then(
(res)=>{
 if(res.data.code==200)
{ this.daptData=[],
 this.daptData2=[],
this.ceshi=[];
console.log(res.data) this.ceshi = res.data.data
for(let i=0;i<this.ceshi.length;i++)
{ for(let j=0;j<this.ceshi[i].policyInfoList.length;j++)
{ this.daptData2[this.ce]={ces:this.ce}
Object.assign(this.daptData2[this.ce], this.ceshi[i],this.ceshi[i].policyInfoList[j]) this.ce++
                    }//将数据的对象直接接到想接到的对象后面
                }
this.daptData=this.daptData2 //生成的新数组可能格式会出现问题,所以新赋值一个数组
            }else { this.$alert(res.data.msg)
            }
        }
    )

},
游客


返回顶部

公众号

公众号