React - 获取form表单数据

---------------------分割线-------------------------

import React,{forwardRef,Ref,UseRef} from 'react'

import {Form,Input,Modal} from 'antd'

----- 重要代码 ---- 需要用下列包括起来

const WrappedForm = Form.create({})(forwardRef(FromDemo ))

function FromDemo (props,ref) {

//包裹后
const { form } = props

const getFieldValue = form.getFieldValue()

const layout = { // form input位置

labelCol:{span:4},

wrapperCol:{span:16}

}

return (


<Form { ...layout }>

<Form.Item label="名称">

<Form.Item>

)
}
function FormComponent () {

const formRef = useRef()

return (

// 这里需要包裹出去 取到ref form的值

)
}

export default forwardRef(FormComponent)

---------------------分割线-------------------------

posted @ 2020-05-13 11:41  Howar丶张  阅读(7119)  评论(0)    收藏  举报