Loloao / my-blog

my first blog
0 stars 0 forks source link

antd 中的 checkbox 和 switch 取值问题 #5

Open Loloao opened 4 years ago

Loloao commented 4 years ago

checkbox 和 switch 使用 Form.Item 时不能直接通过 getFieldsValue 或 getFieldValue 获取,此时需要获取 checked 的值

<FormItem label="初始化模板"> 
  {getFieldDecorator('use_template', {
    rules: [
      { required: true }
    ],
    valuePropName: 'checked'
  })(<Switch />)}
</FormItem>