我正在尝试使用React-Bootstrap获取表单输入的值。在React功能组件中从React Bootstrap表单获取表单值的标准流程是什么?
export default function SpouseForm() {
const dispatch = useContext(DispatchContext);
return (
<Form>
<Row>
<Col xs={12} md={12} lg={{ span: 6, offset: 3 }}>
<InputGroup className="mb-3">
<InputGroup.Prepend>
<InputGroup.Text>Age</InputGroup.Text>
</InputGroup.Prepend>
<FormControl /> <--------- I want to get this value on submit /////////////////
</InputGroup>
</Col>
</Row>
<Row>
<Col xs={12} md={12} lg={{ span: 6, offset: 3 }}>
<Button
onClick={(e) => {
e.preventDefault()
dispatch({ type: "SPOUSE_AGE", spouseAge: e.target.value }); < ----- tried to get it here, not working
router.push('/children')
}}
style={{ width: '100%' }}
type="submit"
variant="outline-primary"
size="lg" >Next</Button>{' '}
</Col>
</Row>
</Form>
)
}
FormData
类/对象来自哪里? - Itay Moav -Malimovka