Basic.tsx 1.61 KB
Newer Older
李纪文's avatar
李纪文 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// @ts-ignore
import React, { useEffect, useState } from 'react';
import TreeCustom from '../index';
import { HomeOutlined } from '@ant-design/icons';

const Demo = (props) => {
  const treeData = [
    {
      title: '熊猫智慧水务',
      key: '0-0',
      children: [
        {
          title: '平台研发部',
          key: '0-0-0',
          children: [
            {
              title: '研发一部',
              key: '0-0-0-0',
            },
            {
              title: '研发二部',
              key: '0-0-0-1',
            },
            {
              title: '研发三部',
李纪文's avatar
李纪文 committed
26
              key: '0-0-0-2',
李纪文's avatar
李纪文 committed
27 28 29
            },
            {
              title: '研发四部',
李纪文's avatar
李纪文 committed
30
              key: '0-0-0-3',
李纪文's avatar
李纪文 committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
            },
          ],
        },
        {
          title: '项目实施部',
          key: '0-0-1',
          children: [],
        },
        {
          title: '售前支持部',
          key: '0-0-2',
          children: [],
        },
        {
          title: '熊猫智慧水务运营部',
          key: '0-0-3',
          children: [],
        },
        {
          title: '智慧水务办公室',
          key: '0-0-4',
          children: [],
        },
      ],
    },
  ];
  const onSelect = (selectedKeys, info) => {
    console.log('selected', selectedKeys, info);
  };
  const onCheck = (checkedKeys, info) => {
    console.log('onCheck', checkedKeys, info);
  };
  return (
    <TreeCustom
      defaultSelectedKeys={['0-0-0']}
      defaultExpandedKeys={['0-0-0']}
      onSelect={onSelect}
      onCheck={onCheck}
      treeData={treeData}
    />
  );
};

export default Demo;