//IterationDelateMenuChildren函数删除空的children数组
IterationDelateMenuChildren(rt) {
if (rt.length) {
for (let i in rt) {
if (rt[i].children.length) {
IterationDelateMenuChildren(rt[i].children);
} else {
delete rt[i].children;
}
}
}
return rt;
}
树形结构数据格式:
options:[{
value: '1',
label: '数据一',
children:[{
value: '2',
label: '数据一',
children:[
{
value: '3',
label: '数据三',
children:[], //需要删除的children
}
]
}],
children:[{
value: '4',
label: '数据四',
children:[
{
value: '5',
label: '数据五',
children:[], //需要删除的children
}
]
}]
}]