2015-12-28 19:16:02 +08:00
|
|
|
# 基本
|
|
|
|
|
|
|
|
- order: 0
|
|
|
|
|
|
|
|
最简单的用法。
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { TreeSelect } from 'antd';
|
|
|
|
const TreeNode = TreeSelect.TreeNode;
|
|
|
|
|
|
|
|
const Demo = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
2016-02-01 14:36:41 +08:00
|
|
|
value: '',
|
2015-12-28 19:16:02 +08:00
|
|
|
};
|
|
|
|
},
|
2016-01-15 20:10:46 +08:00
|
|
|
onChange(value) {
|
2016-02-01 14:36:41 +08:00
|
|
|
console.log(arguments);
|
2016-01-23 15:30:14 +08:00
|
|
|
this.setState({ value });
|
2015-12-28 19:16:02 +08:00
|
|
|
},
|
|
|
|
render() {
|
2016-02-01 17:06:54 +08:00
|
|
|
return (
|
2016-02-22 23:51:26 +08:00
|
|
|
<TreeSelect style={{ width: 300 }}
|
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-02-01 17:06:54 +08:00
|
|
|
placeholder="请选择"
|
2016-02-26 17:12:56 +08:00
|
|
|
allowClear
|
2016-01-21 17:14:39 +08:00
|
|
|
treeDefaultExpandAll
|
|
|
|
onChange={this.onChange}>
|
|
|
|
<TreeNode value="parent 1" title="parent 1" key="0-1">
|
|
|
|
<TreeNode value="parent 1-0" title="parent 1-0" key="0-1-1">
|
|
|
|
<TreeNode value="leaf1" title="my leaf" key="random" />
|
|
|
|
<TreeNode value="leaf2" title="your leaf" key="random1" />
|
2015-12-28 19:16:02 +08:00
|
|
|
</TreeNode>
|
2016-01-21 17:14:39 +08:00
|
|
|
<TreeNode value="parent 1-1" title="parent 1-1" key="random2">
|
2016-02-01 17:06:54 +08:00
|
|
|
<TreeNode value="sss" title={<b style={{ color: '#08c' }}>sss</b>} key="random3" />
|
2016-01-21 17:14:39 +08:00
|
|
|
</TreeNode>
|
|
|
|
</TreeNode>
|
|
|
|
</TreeSelect>
|
2016-02-01 17:06:54 +08:00
|
|
|
);
|
2015-12-28 19:16:02 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2016-02-01 17:06:54 +08:00
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
2015-12-28 19:16:02 +08:00
|
|
|
````
|