Skip to content

Commit e893e64

Browse files
committed
InputNumber required 设置时,空值强制设置为 0
1 parent eef1121 commit e893e64

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/form/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function getFormItemComponent(that) {
469469
});
470470
}
471471
onChangeOrBlurEvent = (e, shouldValidate) => {
472-
const { noFormItem, type } = this.props;
472+
const { noFormItem, type, required } = this.props;
473473
let value;
474474
if (e === undefined) {
475475
value = undefined;
@@ -490,6 +490,11 @@ function getFormItemComponent(that) {
490490
value = '';
491491
}
492492
}
493+
if (type === 'input-number') {
494+
if ((value === '' || value === undefined) && required) {
495+
value = 0;
496+
}
497+
}
493498
if (!noFormItem && shouldValidate) {
494499
this.validateField(this.name, value, this.props.rules);
495500
} else {

0 commit comments

Comments
 (0)