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({
|
2016-02-17 15:57:33 +08:00
|
|
|
getInitialState() {
|
2015-07-17 16:06:46 +08:00
|
|
|
return {
|
2016-02-20 16:39:49 +08:00
|
|
|
value: 1
|
2015-07-17 16:06:46 +08:00
|
|
|
};
|
|
|
|
},
|
2015-07-21 16:18:27 +08:00
|
|
|
onChange(e) {
|
2016-02-20 16:39:49 +08:00
|
|
|
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() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<RadioGroup onChange={this.onChange} value={this.state.value}>
|
2016-02-20 16:39:49 +08:00
|
|
|
<Radio key="a" value={1}>A</Radio>
|
|
|
|
<Radio key="b" value={2}>B</Radio>
|
|
|
|
<Radio key="c" value={3}>C</Radio>
|
|
|
|
<Radio key="d" value={null}>D</Radio>
|
2016-01-07 16:29:12 +08:00
|
|
|
</RadioGroup>
|
|
|
|
</div>
|
|
|
|
);
|
2015-07-17 16:06:46 +08:00
|
|
|
}
|
|
|
|
});
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2015-07-17 16:06:46 +08:00
|
|
|
````
|