我已按照以下教程创建了category hierarchy
:Model Tree Structures with An Array of Ancestors。当我进行查询时,我得到的结果与以下数组转储相同。
[
{id:1,name:'A', ancestors:[]}
,{id:2,name:'AA',parent:1, ancestors:[1]}
,{id:4,name:'AAA',parent:2, ancestors:[1,2]}
,{id:5,name:'AAB',parent:2, ancestors:[1,2]}
,{id:3,name:'AB',parent:1, ancestors:[1]}
,{id:6,name:'ABA',parent:3, ancestors:[1,3]}
,{id:7,name:'ABB',parent:3, ancestors:[1,3]}
,{id:8,name:'B', ancestors:[]}
]
任何人都可以帮助我产生以下输出,以便在上述数据的视图中使用:
ul
li A
ul
li AA
ul
li AAA
li AAB
li AB
ul
li ABA
li ABB
li B