官网只给了hook的方法,项目没有用到hook,没有在form里面调用,所以不能用submint的方法
代码如下
class ActivationAfter extends Component {
formRef = React.createRef();
handleAdd = () => {
const row = this.formRef.current.validateFields();
console.log(row)
}
render() {
<div>
<Button
onClick={() => {
this.handleAdd();
}}
>
新增数据
</Button>
<Form ref={this.formRef}>
<Form.Item label="执行业务规则" labelCol={{ span: 4 }}
style={{ marginBottom: 10 }}
wrapperCol={{ span: 14 }}
>
<Input placeholder="选择执行业务规则" />
</Form.Item>
</Form>
</div>
}
}
export default ActivationAfter