Basic5.tsx 1.53 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 26 27 28 29 30 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
// @ts-ignore
import React, { useEffect, useState } from 'react';
import { SelectCustom, TreeSelectCustom, Option, OptGroup, SHOW_PARENT } from '../index';
import { HomeOutlined } from '@ant-design/icons';
import './index.less';

const Demo = (props) => {
  const onChange = (newValue) => {
    console.log(`selected ${newValue}`);
  };
  const treeData = [
    {
      value: '崇左水厂',
      title: '崇左水厂',
      children: [
        {
          value: '原水泵站',
          title: '原水泵站',
          children: [
            {
              value: '一期原水泵站',
              title: '一期原水泵站',
            },
            {
              value: '二期原水泵站',
              title: '二期原水泵站',
            },
          ],
        },
        {
          value: '沉淀池',
          title: '沉淀池',
          children: [
            {
              value: '一期沉淀池',
              title: '一期沉淀池',
            },
            {
              value: '二期沉淀池',
              title: '二期沉淀池',
            },
          ],
        },
      ],
    },
  ];
  return (
    <TreeSelectCustom
      showSearch
      style={{
        width: '100%',
        marginBottom: '10px',
      }}
      dropdownStyle={{
        maxHeight: 400,
        overflow: 'auto',
      }}
      placeholder="Please select"
      defaultValue={'二期原水泵站'}
      allowClear
      treeDefaultExpandAll
      onChange={onChange}
      treeData={treeData}
    />
  );
};

export default Demo;