找出所有id对应的值,把所有id保存在一个数组中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var numeData = [{
id: '1',
name: "我",
children: [{
id: '11',
name: "两个我",
children: [{
id: '111',
name: "三个我",
}, ]
}, {
id: '01',
name: "01我",
children: [{
id: '001',
name: "001我",
}, ]
}]
},
{
id: '2',
name: "你",
children: [{
id: '22',
name: "两个你",
children: [{
id: '222',
name: "三个你",
}, ]
}, {
id: '02',
name: "02你",
children: [{
id: '002',
name: "002你",
children: [{
id: '0002',
name: '0002你'
}]
}, ]
}]
},
{
id: '3',
name: "他",
children: [{
id: '33',
name: "两个他",
children: [{
id: '333',
name: "三个他",
}, ]
}, {
id: '03',
name: "03他",
children: [{
id: '003',
name: "003他",
children: [{
id: '0003',
name: '0003他'
}]
}, ]
}]
}
]
</script>
</body>
</html>