87,907
社区成员
发帖
与我相关
我的任务
分享
const { data } = obj
const arr = data.map(el => el)
console.log(arr)
结果
[ { typeid: 2,
txt: '人力资源',
title: '',
children: [ [Object], [Object] ] },
{ typeid: 1,
txt: '计划生育',
title: '',
children: [ [Object], [Object], [Object] ] } ]
<script>
var jsonarry = new Array();
var cArray = new Array();
cArray.push(new child("me", "test", []));
cArray.push(new child("you", "test2", []));
jsonarry.push({
name: "",
txt: "",
children: cArray
});
alert(jsonarry[0].children[0].name);
alert(jsonarry[0].children[1].name);
function child(name, txt, children){
this.name = name;
this.txt = txt;
this.children = children;
}
</script>