2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 0
|
2016-08-05 11:47:31 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 基本
|
|
|
|
en-US: Basic
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-12-28 19:16:02 +08:00
|
|
|
|
2016-08-05 11:47:31 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-12-28 19:16:02 +08:00
|
|
|
最简单的用法。
|
|
|
|
|
2016-08-05 11:47:31 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
The most basic usage.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2015-12-28 19:16:02 +08:00
|
|
|
import { TreeSelect } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-06-19 19:09:08 +08:00
|
|
|
const { TreeNode } = TreeSelect;
|
2015-12-28 19:16:02 +08:00
|
|
|
|
2017-02-19 21:41:54 +08:00
|
|
|
class Demo extends React.Component {
|
|
|
|
state = {
|
|
|
|
value: undefined,
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
onChange = value => {
|
2018-06-23 16:35:42 +08:00
|
|
|
console.log(value);
|
2016-01-23 15:30:14 +08:00
|
|
|
this.setState({ value });
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2015-12-28 19:16:02 +08:00
|
|
|
render() {
|
2016-02-01 17:06:54 +08:00
|
|
|
return (
|
2016-10-14 16:17:26 +08:00
|
|
|
<TreeSelect
|
2016-10-20 21:28:50 +08:00
|
|
|
showSearch
|
2019-10-29 11:24:07 +08:00
|
|
|
style={{ width: '100%' }}
|
2016-02-01 14:36:41 +08:00
|
|
|
value={this.state.value}
|
2016-02-29 16:52:53 +08:00
|
|
|
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
2016-08-05 11:47:31 +08:00
|
|
|
placeholder="Please select"
|
2016-02-26 17:12:56 +08:00
|
|
|
allowClear
|
2016-01-21 17:14:39 +08:00
|
|
|
treeDefaultExpandAll
|
2016-06-06 13:54:10 +08:00
|
|
|
onChange={this.onChange}
|
|
|
|
>
|
2020-02-07 11:07:48 +08:00
|
|
|
<TreeNode value="parent 1" title="parent 1">
|
|
|
|
<TreeNode value="parent 1-0" title="parent 1-0">
|
|
|
|
<TreeNode value="leaf1" title="my leaf" />
|
|
|
|
<TreeNode value="leaf2" title="your leaf" />
|
2015-12-28 19:16:02 +08:00
|
|
|
</TreeNode>
|
2020-02-07 11:07:48 +08:00
|
|
|
<TreeNode value="parent 1-1" title="parent 1-1">
|
|
|
|
<TreeNode value="sss" title={<b style={{ color: '#08c' }}>sss</b>} />
|
2016-01-21 17:14:39 +08:00
|
|
|
</TreeNode>
|
|
|
|
</TreeNode>
|
|
|
|
</TreeSelect>
|
2016-02-01 17:06:54 +08:00
|
|
|
);
|
2017-02-19 21:41:54 +08:00
|
|
|
}
|
|
|
|
}
|
2015-12-28 19:16:02 +08:00
|
|
|
|
2016-02-01 17:06:54 +08:00
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|