Skip to content
On this page

树形组件

多层次的结构列表,使用树控件可以完整展现其中的层级关系,并具有展开收起选择等交互功能。

基础示例,展开第几层

行操作项

右键菜单

可选择及快捷操作

自定义插槽

拖拽示例

连接线

标题前后置

API

属性说明类型默认值版本
action动态渲染每一行后面的操作按钮(row: Recordable) => any[]
activeKey当前处于激活状态的条目idstring | number
addonAfterinput搜索框后置标签slot
addonBeforeinput搜索框前置标签slot
beforeRightClick点击右键动态自定义菜单(...arg: any) => ContextMenuItem[]
blockNode是否节点占据一行booleantrue
checkable节点前添加Checkbox复选框boolean
checkedKeys选中的节点CheckKeys[]
checkStrictly树结构是否粘性选择(父子节点选中状态不再关联)boolean
clickRowToExpand点击行展开子节点booleanfalse
disabled将树禁用booleanfalse
draggable设置节点可拖拽booleanfalse
expandedKeys设置展开的树节点(string | number)[]
expandOnSearch搜索完成时自动展开结果booleantrue
fieldNames替换 treeNode 中 title,key,children 字段为 treeData 中对应的字段FieldNames{ children: 'children', title: 'title',key: 'key' }
filterFn自定义过滤函数(searchValue: any, node: TreeItem, fieldNames: FieldNames) => boolean
filterTreeNode按需筛选树节点(高亮),返回 true(node: Recordable) => boolean
defaultExpandAll默认是否展开所有层级booleanfalse
defaultExpandLevel默认展开的层级string
height使用 height 属性则切换为虚拟滚动string | number
highlight文字高亮的颜色string | number'#f50'
loading加载状态boolean
multiple支持点选多个节点(节点本身)booleanfalse
renderIcon自定义title之前的图标(params: Recordable) => string
rightMenuList右键默认菜单ContextMenuItem[]
search是否显示过滤框boolean
searchValue默认的搜索框内容string
selectable点击行是否可选中booleanfalse
selectedKeys设置选中的key(string | number)[]
showIcon是否显示树结构前面的图标booleanfalse
showLine是否展示连接线booleanfalse
title定义树标题string
toolbar是否显示快速操作栏boolean
treeData树结构绑定的数据TreeDataItem[]

事件

事件名称说明回调参数
changecheckedKeys改变触发(checkedKeys) => void
check点击复选框触发(checkedKeys, e:{checked: bool, checkedNodes, node, event}) => void
clickNode点击节点触发(node: Recordable) => void
dropdrop 触发时调用({ data, info }) => void

FieldNames

属性说明类型默认值版本
children作为children的属性名string
key作为key的属性名string
title作为title的属性名string

CheckKeys

ts
type KeyType = string | number

type CheckKeys =
  | KeyType[]
  | { 
        checked: string[] | number[]; 
        halfChecked: string[] | number[] 
    }