const data = [
{ id:1, pid:0, text:1, children:[{ id:2, pid:1, text:2, children:[{ id:3, pid:2, text:3, children:[]
}]
}]
}
]//怎么查找id的父級的index索引id=3父級2 所在數組index為0,在上父級的id1,所在數組的index 0,直到最頂一層//輸入id 3//返回 [0,0,0] 索引的數組
js,json樹查找父級路徑
狐的傳說
2018-09-08 17:10:49