const data = [
{ id:1, pid:0, text:1, children:[{ id:2, pid:1, text:2, children:[{ id:3, pid:2, text:3, children:[]
}]
}]
}
]//怎么查找id的父級(jí)的index索引id=3父級(jí)2 所在數(shù)組index為0,在上父級(jí)的id1,所在數(shù)組的index 0,直到最頂一層//輸入id 3//返回 [0,0,0] 索引的數(shù)組
js,json樹查找父級(jí)路徑
搖曳的薔薇
2018-09-23 10:18:07