Skip to content

Commit 4ddee05

Browse files
committed
fix(form): fix form inputNumber verification error
1 parent abb0cfa commit 4ddee05

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

CHANGELOG.zh_CN.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
- 更新 antdv 到`2.0.0-rc.1`
1111

12+
### 🐛 Bug Fixes
13+
14+
- 修复表单 inputNumber 校验错误
15+
1216
## 2.0.0-rc.10 (2020-11-13)
1317

1418
### ✨ Refactor

src/components/Form/src/FormItem.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export default defineComponent({
122122
} = props.schema;
123123

124124
if (isFunction(dynamicRules)) {
125-
return dynamicRules(unref(getValuesRef));
125+
return dynamicRules(unref(getValuesRef)) as ValidationRule[];
126126
}
127127

128-
let rules: ValidationRule[] = cloneDeep(defRules);
128+
let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[];
129129

130130
if ((!rules || rules.length === 0) && required) {
131131
rules = [{ required }];
@@ -157,6 +157,9 @@ export default defineComponent({
157157
if (component.includes('RangePicker')) {
158158
rule.type = 'array';
159159
}
160+
if (component.includes('InputNumber')) {
161+
rule.type = 'number';
162+
}
160163
}
161164
}
162165

src/hooks/web/useMessage.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal';
2-
import type { MessageApi } from 'ant-design-vue/lib/message';
32

43
import { Modal, message as Message, notification } from 'ant-design-vue';
54
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
@@ -100,7 +99,7 @@ notification.config({
10099
*/
101100
export function useMessage() {
102101
return {
103-
createMessage: Message as MessageApi,
102+
createMessage: Message,
104103
notification: notification as NotifyApi,
105104
createConfirm: createConfirm,
106105
createSuccessModal,

src/views/demo/form/index.vue

+9
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@
208208
],
209209
},
210210
},
211+
{
212+
field: 'field20',
213+
component: 'InputNumber',
214+
label: '字段20',
215+
required: true,
216+
colProps: {
217+
span: 8,
218+
},
219+
},
211220
];
212221
213222
export default defineComponent({

0 commit comments

Comments
 (0)