You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.2 KiB

---
order: 2
title:
zh-CN: 多选
en-US: Multiple
---
9 years ago
## zh-CN
多选和勾选框功能。
9 years ago
## en-US
Multiple and checkable.
9 years ago
````jsx
import { TreeSelect } from 'antd';
const SHOW_PARENT = TreeSelect.SHOW_PARENT;
9 years ago
const treeData = [{
label: 'Node1',
value: '0-0',
key: '0-0',
children: [{
label: 'Child Node1',
value: '0-0-0',
key: '0-0-0',
}],
}, {
label: 'Node2',
value: '0-1',
key: '0-1',
children: [{
label: 'Child Node3',
value: '0-1-0',
key: '0-1-0',
}, {
label: 'Child Node4',
value: '0-1-1',
key: '0-1-1',
}, {
label: 'Child Node5',
value: '0-1-2',
key: '0-1-2',
}],
}];
9 years ago
const Demo = React.createClass({
getInitialState() {
return {
value: ['0-0-0'],
9 years ago
};
},
9 years ago
onChange(value) {
9 years ago
console.log('onChange ', value, arguments);
9 years ago
this.setState({ value });
9 years ago
},
render() {
9 years ago
const tProps = {
treeData,
9 years ago
value: this.state.value,
onChange: this.onChange,
multiple: true,
9 years ago
treeCheckable: true,
showCheckedStrategy: SHOW_PARENT,
searchPlaceholder: 'Please select',
style: {
width: 300,
},
9 years ago
};
return <TreeSelect {...tProps} />;
9 years ago
},
});
ReactDOM.render(<Demo />, mountNode);
9 years ago
````