Skip to content

Repository files navigation

react-virtual-tree

虚拟列表树(未发布,仅供学习用)


依赖

根据各自项目安装缺少的依赖


本地开发

gitclone https://github.com/imdwpeng/react-virtual-tree.gitcdreact-virtual-treenpmstart

发布

npmrunpub

使用

importVirtualTreefrom'react-virtual-tree';constmenuData=[{id: '1',title: '1',children: [{id: '1-1',title: '1-1'},{id: '1-2',title: '1-2'}]},{id: '2',title: '2',children: [{id: '2-1',title: '2-1'},{id: '2-2',title: '2-2'}]}]<divstyle={{height: 790,width: 160}}><VirtualTreeuniqKey="key"showSwitcherIcon={false}itemHeight={40}dataSource={menuData}selectedKeys={selectedKeys}expandKeys={expandKeys}onExpandChange={handleExpandChange}render={(item)=><div>{item.title}</div>}/></div>

属性

参数说明类型/数据格式默认值
dataSource树结构数据array-
defaultExpandAll默认展开父节点booleanfalse
expandKeys(受控)展开指定的树节点,与onExpandChange配合使用string[]-
itemHeight行高number24
selectedKeys(受控)设置选中的树节点,与onSelect配合使用string[]-
space间隔number24
showSwitcherIcon自定义树节点的展开/折叠图标booleanfalse
uniqKey行 key 的取值string'id'
render渲染节点函数(item) => JSX.Element-
onExpandChange展开/收起节点时触发function(expandedKeys)-
onSelect点击树节点触发function(selectedNode)-

历史记录

详情请参考 CHANGELOG

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages