首页 > 应用开发 > > Antd Tree控件如何动态添加删除节点?
async getAllEntry() //保存数据的
{
let menus =
[
{ id : "1", name : "IT开发部"} ,
{ id : "2", name : "行政部"} ,
{ id : "21", name : "会计部", parentId : "2"} ,
{ id : "22", name : "出纳部", parentId : "2"} ,
{ id : "3", name : "咨询部"} ,
]
returnmenus;
}
<DirectoryTree
multiple
defaultExpandAll
onSelect={this.onSelect}
onExpand={this.onExpand}
>
{
( function()
{
let subOrg = function(parentId)
{
returnorgs.filter( org => parentId ? ( org.parentId == parentId ) : ( org.parentId == null) ).map( org =>
{
return(
<TreeNode title={org.name} key={org.id} >
{
subOrg( org.id )
}
</TreeNode>
);
} )
};
returnsubOrg();
} )()
}
</DirectoryTree>
这个是我写的树结构,现在想要实现:点击一个按钮,就在当前节点下创建或者删除一个新的子节点。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4571/viewspace-3121843/ ,如需转载,请注明出处,否则将追究法律责任。