如上图所示,是一个单选按钮,如果需要获取单选按钮的默认值,那样怎么处理呢?
代码:
class FilterForm extends ListFilterForm {
constructor() {
super();
this.state = { //先声明变量并初始化
isAll: true
}
}
handleSubmit= (value) => {
};
handleChecked = (event) => {
this.setState({ isAll: event.target.checked });
};
render() {
const { isAll }=this.state;
return (
<Form onSubmit={this.handleSubmit} inline={true}>
/*单选按钮*/
<FormItem>
{getFieldDecorator('isAll', {
valuePropName: 'checked',
initialValue: isAll || false,
})(
<Checkbox onChange={this.handleChecked}>未指派房行</Checkbox>
)}
</FormItem>
<Button type="primary" htmlType="submit">提交</Button>
</Form>
)
}
}