今天你抽象了吗*(js小函数)*
- 树形过滤最后一个节点必须有数据,没有数据的叶子 不显示
- 树枝A(type:D)
+ 树叶AA(type:L) - 树枝B
+ 树枝BB(type:D)
- 树枝A(type:D)
- 过滤掉树枝B
//排版不行
function filterTreeData(Node){
if(Node.Type=="L") {
return Node;
}
else{
if(Node.Children && Node.Children.length>0 ){
let cs = $.map(Node.Children,d=>filterTreeData(d)).filter(d=>d);
Node.Children = cs;
}
if(Node.Children.length==0) {
return null;
}
else{
return Node;
}
}
}
2.关于validate