Browse Source

fix: defaultValue类型为number时的bug (#3288)

黄小民 1 year ago
parent
commit
3b2760ca3a
1 changed files with 9 additions and 3 deletions
  1. 9 3
      src/components/Form/src/helper.ts

+ 9 - 3
src/components/Form/src/helper.ts

@@ -61,9 +61,17 @@ export function processDateValue(attr: Recordable, component: string) {
   }
 }
 
+export const defaultValueComponents = [
+  'Input',
+  'InputPassword',
+  'InputNumber',
+  'InputSearch',
+  'InputTextArea',
+];
+
 export function handleInputNumberValue(component?: ComponentType, val?: any) {
   if (!component) return val;
-  if (['Input', 'InputPassword', 'InputSearch', 'InputTextArea'].includes(component)) {
+  if (defaultValueComponents.includes(component)) {
     return val && isNumber(val) ? `${val}` : val;
   }
   return val;
@@ -74,8 +82,6 @@ export function handleInputNumberValue(component?: ComponentType, val?: any) {
  */
 export const dateItemType = genType();
 
-export const defaultValueComponents = ['Input', 'InputPassword', 'InputSearch', 'InputTextArea'];
-
 // TODO 自定义组件封装会出现验证问题,因此这里目前改成手动触发验证
 export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
   'Upload',