docs: Update Tree demo to use treeData (#25916)

* docs: Update Tree demo to use treeData

* clean up
This commit is contained in:
二货机器人 2020-07-30 18:12:45 +08:00 committed by GitHub
parent 3d58b5a6b4
commit 3b7d23485a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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',
},
],
},
],
},
]}
/>
); );
} }
} }