1.5.2 • Published 3 years ago

react-tree-th v1.5.2

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

一款基于 react 的 tree 组件

这是一款轻量的 tree 组件,可以异步加载,可以自定义节点,支持巨量数据渲染等等功能

Tree Demo

Props

参数说明类型默认值
className节点类名string-
style节点样式CSSProperties-
data数据源array<{id, value, [sub, expand, isLeaf]}>[]
expandedKeys展开指定的树节点string[]-
showLine是否展示连接线booleanfalse
showExpand是否展示收缩器按钮booleantrue
expandStyle收缩器按钮类型stringplus
expandColor收缩器按钮颜色stringrgba(0, 0, 0, 0.4)
lineColor连接线颜色stringrgba(0, 0, 0, 0.4)
hoverBgColor鼠标移入颜色(传入 false 则无效果)string#e1e1fa
hoverBlock触发鼠标移入的区域stringinline
lineBoxWidth连接区域宽度string30px
itemRender自定义渲染节点(nodeData, index, parentData) => ReactNode-
itemStyle节点样式CSSProperties{ padding: '4px', whiteSpace: 'nowrap' }
defaultExpand默认是否展开booleantrue
height开启虚拟滚动boolean | numberfalse
itemSize单行高度number24
loadData异步加载数据(节点必须有 isLeaf 属性才可以触发)(nodeData) => Promise-
onExpand展开/收起节点时触发function(expandedKeys, {expanded: bool, node})-
onClick点击事件function(nodeData)-
onChange组件数据变化时触发function(nodeData)-

Ref

参数说明类型默认值
update在某些特殊情况下(eg: 自定义渲染节点并且操作节点数据),需要手动更新组件数据() => void-
change在某些特殊情况下(eg: 自定义渲染节点并且操作节点数据),需要手动向上传递组件数据() => void-

Data Props

[
  {
    id: '1-1', // key
    value: '一级标题', // 展示文案
    expand: true, // 是否展开
    isLeaf: true, // 设置为叶子节点(设置了 loadData 时有效)。为 false 时会强制将其作为父节点
    sub: [
      // 子节点(非必须)
      {
        id: '2-1',
        value: '二级标题',
        sub: [
          {
            id: '3-1',
            value: '三级标题',
          },
        ],
      },
    ],
  },
];

ExpandStyle Props

  • plus
  • triangle

HoverBlock Props

  • inline
  • block
1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.3.3

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago