Browse Source

fix(Form组件): 修复defaultValue=0不生效的问题

shizhongming 2 years ago
parent
commit
700d5e8e9c
  1. 6
      src/components/Form/src/hooks/useFormEvents.ts

6
src/components/Form/src/hooks/useFormEvents.ts

@ -2,7 +2,7 @@ import type { ComputedRef, Ref } from 'vue';
import type { FormProps, FormSchemaInner as FormSchema, FormActionType } from '../types/form'; import type { FormProps, FormSchemaInner as FormSchema, FormActionType } from '../types/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface'; import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue'; import { unref, toRaw, nextTick } from 'vue';
import { isArray, isFunction, isObject, isString, isDef, isNil } from '@/utils/is'; import { isArray, isFunction, isObject, isString, isDef, isNil, isNumber } from '@/utils/is';
import { deepMerge } from '@/utils'; import { deepMerge } from '@/utils';
import { import {
dateItemType, dateItemType,
@ -377,6 +377,10 @@ function getDefaultValue(
let defaultValue = cloneDeep(defaultValueRef.value[key]); let defaultValue = cloneDeep(defaultValueRef.value[key]);
const isInput = checkIsInput(schema); const isInput = checkIsInput(schema);
if (isInput) { if (isInput) {
// TODO: 默认值0不生效问题解决
if (isNumber(defaultValue)) {
return defaultValue;
}
return defaultValue || undefined; return defaultValue || undefined;
} }
if (!defaultValue && schema && checkIsRangeSlider(schema)) { if (!defaultValue && schema && checkIsRangeSlider(schema)) {

Loading…
Cancel
Save