2015-08-21 18:24:09 +08:00
|
|
|
# RadioGroup 组合
|
2015-07-17 16:06:46 +08:00
|
|
|
|
|
|
|
- order: 1
|
|
|
|
|
2015-08-21 18:24:09 +08:00
|
|
|
一组互斥的 Radio 配合使用。
|
2015-07-17 16:06:46 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Radio } from 'antd';
|
|
|
|
const RadioGroup = Radio.Group;
|
2015-07-17 16:06:46 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
const App = React.createClass({
|
2015-07-17 16:06:46 +08:00
|
|
|
getInitialState: function () {
|
|
|
|
return {
|
2015-07-21 16:18:27 +08:00
|
|
|
value: 'a'
|
2015-07-17 16:06:46 +08:00
|
|
|
};
|
|
|
|
},
|
2015-07-21 16:18:27 +08:00
|
|
|
onChange(e) {
|
|
|
|
console.log('radio checked:' + e.target.value);
|
2015-07-17 16:06:46 +08:00
|
|
|
this.setState({
|
2015-07-21 16:18:27 +08:00
|
|
|
value: e.target.value
|
|
|
|
});
|
2015-07-17 16:06:46 +08:00
|
|
|
},
|
|
|
|
render() {
|
2015-08-17 17:03:16 +08:00
|
|
|
return <div>
|
2015-07-20 22:36:49 +08:00
|
|
|
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
|
|
|
<Radio value="a">A</Radio>
|
2015-07-21 16:18:27 +08:00
|
|
|
<Radio value="b">B</Radio>
|
|
|
|
<Radio value="c">C</Radio>
|
|
|
|
<Radio value="d">D</Radio>
|
2015-07-17 16:06:46 +08:00
|
|
|
</RadioGroup>
|
2015-07-21 16:18:27 +08:00
|
|
|
<div style={{marginTop: 20}}>你选中的: {this.state.value}</div>
|
2015-08-17 17:03:16 +08:00
|
|
|
</div>;
|
2015-07-17 16:06:46 +08:00
|
|
|
}
|
|
|
|
});
|
2015-10-20 16:47:55 +08:00
|
|
|
ReactDOM.render(<App />, document.getElementById('components-radio-demo-radiogroup'));
|
2015-07-17 16:06:46 +08:00
|
|
|
````
|