antd——form表单监听表单域
2018-04-19 本文已影响0人
芒果加奶
需求:监听整个form表单,当任意表单域改变时触发,实现是否编辑功能。

刚开始打算监听每个formItem的onchange事件,很麻烦,监听form表单整个表单域是最方便的,又开始在api中寻找。果然有方法。。

我使用的onValuesChange
,onFieldsChange
文档介绍了,实际没有尝试这个方法。
代码如下:
export default connect(mapStateToProps, mapDisptchToProps)(
Form.create({
onValuesChange(props, values) {
// 表单域改变时触发actions方法,控制isEdit为true
props.actions.changeCarEvaluate();
}
})(Car)
);