ant-design/components/tree/demo/directory.md
zombieJ 8114516496
feat: Tree support virtual scroll (#18172)
* update tree deps

* add part of style

* flex grid

* update disabled

* update demo

* second demo

* add draggable style

* update demo

* update rc-tree version

* temp md

* update tree deps

* update icon demo

* update style

* update less

* update deps

* clean up

* update test case

* fix show line

* update snapshot

* fix lint

* update style

* update deps
2019-08-12 13:22:36 +08:00

1.1 KiB

order title
7
zh-CN en-US
目录 directory

zh-CN

内置的目录树,multiple 模式支持 ctrl(Windows) / command(Mac) 复选。

en-US

Built-in directory tree. multiple support ctrl(Windows) / command(Mac) selection.

import { Tree } from 'antd';

const { DirectoryTree } = Tree;

const treeData = [
  {
    title: 'parent 0',
    key: '0-0',
    children: [
      { title: 'leaf 0-0', key: '0-0-0', isLeaf: true },
      { title: 'leaf 0-1', key: '0-0-1', isLeaf: true },
    ],
  },
  {
    title: 'parent 1',
    key: '0-1',
    children: [
      { title: 'leaf 1-0', key: '0-1-0', isLeaf: true },
      { title: 'leaf 1-1', key: '0-1-1', isLeaf: true },
    ],
  },
];

const Demo: React.FC<{}> = () => {
  const onSelect = (keys, event) => {
    console.log('Trigger Select', keys, event);
  };

  const onExpand = () => {
    console.log('Trigger Expand');
  };

  return (
    <DirectoryTree
      multiple
      defaultExpandAll
      onSelect={onSelect}
      onExpand={onExpand}
      treeData={treeData}
    />
  );
};

ReactDOM.render(<Demo />, mountNode);