```javascript
/*
* Auth: WANGJIAN
*/
function familyTree(arr) {
var temp = [];
var forFn = function(arr, temp){
arr.forEach(item=>{
var obj= {};
obj.name=item.name;
if(item.chirden){
obj.chirden=[]
forFn(item.chirden,obj.chirden);
}
temp.push(obj)
})
};
forFn(arr, temp);
return temp;
}
var data =[{id:1,name:'张三',chirden:[{name:2,name:'李四'}]},{id:3,name:'李二'}]
console.log(familyTree(data));
```
博客描述
js递归菜单树,省市区三级