mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-11 10:05:07 +08:00
docs: Update Tree demo to use treeData (#25916)
* docs: Update Tree demo to use treeData * clean up
This commit is contained in:
parent
3d58b5a6b4
commit
3b7d23485a
@ -17,8 +17,6 @@ customize collapse/expand icon of tree node
|
|||||||
import { Tree } from 'antd';
|
import { Tree } from 'antd';
|
||||||
import { DownOutlined } from '@ant-design/icons';
|
import { DownOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
const { TreeNode } = Tree;
|
|
||||||
|
|
||||||
class Demo extends React.Component {
|
class Demo extends React.Component {
|
||||||
onSelect = (selectedKeys, info) => {
|
onSelect = (selectedKeys, info) => {
|
||||||
console.log('selected', selectedKeys, info);
|
console.log('selected', selectedKeys, info);
|
||||||
@ -31,22 +29,57 @@ class Demo extends React.Component {
|
|||||||
switcherIcon={<DownOutlined />}
|
switcherIcon={<DownOutlined />}
|
||||||
defaultExpandedKeys={['0-0-0']}
|
defaultExpandedKeys={['0-0-0']}
|
||||||
onSelect={this.onSelect}
|
onSelect={this.onSelect}
|
||||||
>
|
treeData={[
|
||||||
<TreeNode title="parent 1" key="0-0">
|
{
|
||||||
<TreeNode title="parent 1-0" key="0-0-0">
|
title: 'parent 1',
|
||||||
<TreeNode title="leaf" key="0-0-0-0" />
|
key: '0-0',
|
||||||
<TreeNode title="leaf" key="0-0-0-1" />
|
children: [
|
||||||
<TreeNode title="leaf" key="0-0-0-2" />
|
{
|
||||||
</TreeNode>
|
title: 'parent 1-0',
|
||||||
<TreeNode title="parent 1-1" key="0-0-1">
|
key: '0-0-0',
|
||||||
<TreeNode title="leaf" key="0-0-1-0" />
|
children: [
|
||||||
</TreeNode>
|
{
|
||||||
<TreeNode title="parent 1-2" key="0-0-2">
|
title: 'leaf',
|
||||||
<TreeNode title="leaf" key="0-0-2-0" />
|
key: '0-0-0-0',
|
||||||
<TreeNode title="leaf" key="0-0-2-1" />
|
},
|
||||||
</TreeNode>
|
{
|
||||||
</TreeNode>
|
title: 'leaf',
|
||||||
</Tree>
|
key: '0-0-0-1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'leaf',
|
||||||
|
key: '0-0-0-2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'parent 1-1',
|
||||||
|
key: '0-0-1',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
title: 'leaf',
|
||||||
|
key: '0-0-1-0',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'parent 1-2',
|
||||||
|
key: '0-0-2',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
title: 'leaf',
|
||||||
|
key: '0-0-2-0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'leaf',
|
||||||
|
key: '0-0-2-1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user