varres=[{code:1,name:"湖北省",children:[{code:1,name:"武汉市",children:[{code:1,name:"汉阳区",children:[{code:1,name:"水上分局1"}]},{code:1,name:"武昌区",children:[{code:1,name:"水上分局2"}]},{code:1,name:"汉口区",children:[{code:1,name:"水上分局3"}]}]},{code:1,name:"十堰市",children:[{code:1,name:"郧阳区",children:[{code:1,name:"安阳镇"}]},{code:1,name:"茅箭区",children:[{code:1,name:"小川乡"}]}]}]}]已知树形结构res。现在有一个对象是{code:1,name:"水上分局"},想向上依次获取取得父级,比如说水上分局父节点是汉阳区汉阳区父节点是武汉市武汉市父节点是湖北省最后将汉阳区武汉市湖北省存起来求指点
添加回答
举报
0/150
提交
取消