多级嵌套的对象数组,有一个id,根据这个id去查找,和这个id有关系的id,我的写法如下,不知道哪里有问题?
如下,id为113,希望获取到的为1,11,113这样的数组(不要通过str.splice等方式实现)
var arr = [
{
"menuId": 1,
"menuName": "物联网",
"defaultIcon": "icon-wulianwangjiankong",
"path": "/internet_things",
"childs": [
{
"menuId": 11,
"menuName": "首页",
"defaultIcon": "icon-home",
"path": "/internet_things/home",
"childs": [
{
"menuId": 111,
"menuName": "数据分析",
"defaultIcon": "",
"path": "/internet_things/home/data_analyse",
"childs": []
},
{
"menuId": 112,
"menuName": "设备分布",
"defaultIcon": "",
"path": "/internet_things/home/device_loc",
"childs": []
}
]
}
]
}
];
POPMUISE
Helenr
相关分类