antdesign 表单中的单选按钮处理

这里写图片描述

如上图所示,是一个单选按钮,如果需要获取单选按钮的默认值,那样怎么处理呢?

代码:

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>
          )
}

}

猜你喜欢

转载自blog.csdn.net/qq_24147051/article/details/80772927
今日推荐