1.调用antd的Form表单

import { Form } from 'antd'
const FormItem = Form.Item

const { getFieldValue, validateFieldsAndScroll } = this.props.form

state={

fs:‘’

}

2.在组件中使用

const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form

<FormItem >

{getFieldDecorator('fs', { rules: [ { required: true, message: '*请输入份数' }, { pattern: /^\+?[1-9][0-9]*$/, message: '*请输入正确份数' } ] })( <Input className='basic' placeholder='请输入' maxLength={9} autoComplete='off' style={{ width: '100%' }} /> )} </FormItem>

3.提交方法、取值

 validateFieldsAndScroll(async (errors, values) => {
      if (!errors) {
                fs: getFieldValue('fs')
        })

您已经阅读00:00:00欢迎留言评论,喜欢的话就为作者点个赞或者赏颗糖吧! 分享