如何获取单选按钮的值,如果我在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>