【发布时间】:2018-03-25 12:55:32
【问题描述】:
如何获取单选按钮的值,如果我在 RadioGroup 中调用 updateRadioButton 会导致错误。我需要使用(react-radio-buttons)在控制台中打印为男性或女性。单选按钮打印正确,但我无法获得值。提前谢谢你。
class CreateUserComponent extends React.Component {
constructor(props) {
super(props);
this.state={radio:''}
}
updateRadioButton(e) {
this.setState({ radio: e.target.value });
}
<RadioGroup horizontal>
<RadioButton value="Male">Male</RadioButton>
<RadioButton value="Female">Female</RadioButton>
</RadioGroup>
【问题讨论】:
标签: reactjs radio-button