Ant Design中的Form组件

1. 使用Form.create()包裹过的组件可以获取到this.props.form属性

Form.create()(Comp)

2. getFieldDecorator()

 1 // 在表单中的使用
 2 <FormItem>
 3    {
 4      getFieldDecorator('field', {
 5        rules: [{}],
 6        // ...
 7      })(
 8        // 相关form组件
 9     )
10   }
11 </FormItem>

3. getFieldsValue()

render() {
  const { getFieldsValue } = this.props.form
  // 获取全部表单项的value
  const allValue = getFieldsValue()
  // 获取field与查询值相匹配表单项的value
  const spcValue = getFieldsValue(['field1', 'field2', '...'])
}

猜你喜欢

转载自www.cnblogs.com/fanqshun/p/10010130.html