// 找出对应 id 的 name,obj是后台返回的json数据格式,是深部不同的数组
function getUname(lists, id) {
const hasChildrenAttr = function (obj) {
return obj.child !== undefined
}
lists.forEach(list => {
console.log(list.orgnization_id,id)
if (list.orgnization_id == id) {
console.log(list) //此处可以打印
return list
} else {
if (hasChildrenAttr(list)) {
if (list.child && list.child.length > 0){
return getUname(list.child, id)
}
}
}
})
}
console.log(getUname(obj,"9"))