博客
关于我
Ant Design中Tree组件使用
阅读量:335 次
发布时间:2019-03-04

本文共 2468 字,大约阅读时间需要 8 分钟。

import React, { Component } from 'react'import { Tree } from 'antd'const { DirectoryTree } = Tree;export default class TreeComponent extends Component {    state = {}    getTreeData = () => {        return [            {                title: '机构一',                key: '0-0',                children: [                    {                        title: '用户一',                        key: '0-0-0',                        isLeaf: true                    },                    {                        title: '用户二',                        key: '0-0-1',                        isLeaf: true                    },                    {                        title: '用户三',                        key: '0-0-2',                        isLeaf: true                    },                    {                        title: '用户四',                        key: '0-0-3',                        isLeaf: true                    },                    {                        title: '用户五',                        key: '0-0-4',                        isLeaf: true                    },                    {                        title: '用户六',                        key: '0-0-5',                        isLeaf: true                    }                ]            },            {                title: '机构二',                key: '0-1',                children: [                    {                        title: '用户七',                        key: '0-1-0',                        isLeaf: true                    },                    {                        title: '用户八',                        key: '0-1-1',                        isLeaf: true                    },                    {                        title: '用户九',                        key: '0-1-2',                        isLeaf: true                    },                    {                        title: '用户十',                        key: '0-1-3',                        isLeaf: true                    }                ]            }        ];    }    onSelect = (selectedKeys, info) => {        console.log('selected', selectedKeys, info);    };    onCheck = (checkedKeys, info) => {        console.log('onCheck', checkedKeys, info);    };    componentWillMount() {        this.treeData = this.getTreeData();    }    render() {        return (            
); }}

优化说明:

  • 删除了无效的HTML标签和空白内容
  • 使用更简洁的代码格式,符合技术文档标准
  • 保留了核心功能模块的必要描述
  • 使用更专业的技术术语
  • 保持了代码的可读性和可维护性
  • 删除了不影响功能的默认属性设置
  • 保持了与原代码一致的核心功能
  • 转载地址:http://umvq.baihongyu.com/

    你可能感兴趣的文章
    Pandas DataFrame中的列从浮点数输出到货币(负值)
    查看>>
    Pandas DataFrame中的列从浮点数输出到货币(负值)
    查看>>
    Pandas DataFrame多索引透视表-删除空头和轴行
    查看>>
    pandas DataFrame的一些操作
    查看>>
    Pandas Dataframe的日志文件
    查看>>
    Pandas df.iterrows() 并行化
    查看>>
    Pandas drop_duplicates 方法不适用于包含列表的数据框
    查看>>
    pandas groupby 和过滤器
    查看>>
    pandas GROUPBY+变换和多列
    查看>>
    pandas Groupby:创建两列的Groupby时,如何按正确的顺序对工作日进行排序?
    查看>>
    Pandas matplotlib 无法显示中文
    查看>>
    pandas PIVOT_TABLE保持索引
    查看>>
    Pandas Plots:周末的单独颜色,x 轴上漂亮的打印时间
    查看>>
    pandas to_latex() 转义数学模式
    查看>>
    Pandas | 频数统计很简单,但这5 种技巧你使用过吗?
    查看>>
    Pandas 中文官档 ~ 基础用法4
    查看>>
    pandas 中的 for 循环真的很糟糕吗?我什么时候应该关心?
    查看>>
    Pandas 中的多索引旋转
    查看>>
    Pandas 中的日期范围
    查看>>
    pandas 中的时间序列箱线图
    查看>>