`
var list = [{
"orgId": 1,
"orgName": "校长办公室1",
"parentId": 0
},{
"orgId": 2,
"orgName": "校长办公室2",
"parentId": 1,
},{
"orgId": 3,
"orgName": "校长办公室3",
"parentId": 2,
}];
function findParent(idx){list.forEach(item => {if (idx === item['orgId']){let pid = item['parentId']console.log(pid)findParent(pid)}})}findParent(3); //2 1 0
`
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)