1.json树数据查找所有父级--完成

json:树结构数据

var arrData = [{
    "label": "中国",
    "City": null,
    "value": "0",
    "children": [{
            "label": "河北",
            "City": "0",
            "value": "1",
            "children": [{
                    "label": "石家庄",
                    "City": "1",
                    "value": "1.1",
                    "children": null
                },
                {
                    "label": "保定",
                    "City": "1",
                    "value": "1.2",
                    "children": null
                },
                {
                    "label": "邯郸",
                    "City": "1",
                    "value": "1.3",
                    "children": [{
                            "label": "邯山区",
                            "City": "1.3",
                            "value": "1.3.1",
                            "children": [{
                                "label": "丛西街道",
                                "City": "1.3.1",
                                "value": "1.3.1.1",
                                "children": null
                            }]
                        },
                        {
                            "label": "涉县",
                            "City": "1.3",
                            "value": "1.3.2",
                            "children": null
                        },
                        {
                            "label": "丛台区",
                            "City": "1.3",
                            "value": "1.3.3",
                            "children": null
                        }
                    ]
                }
            ]
        },
        {
            "label": "山东",
            "City": "0",
            "value": "2",
            "children": [{
                "label": "济南",
                "City": "2",
                "value": "2.1",
                "children": null
            }]
        },
        {
            "label": "北京",
            "City": "0",
            "value": "3",
            "children": null
        }

    ]
}];
View Code

相关文章: