From 700d5e8e9c0591f0df41dbe9aa885ed69d30d597 Mon Sep 17 00:00:00 2001 From: shizhongming Date: Thu, 25 Apr 2024 21:05:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(Form=E7=BB=84=E4=BB=B6):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DdefaultValue=3D0=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/hooks/useFormEvents.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index a991539cc..cb8443618 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/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 { NamePath } from 'ant-design-vue/lib/form/interface'; 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 { dateItemType, @@ -377,6 +377,10 @@ function getDefaultValue( let defaultValue = cloneDeep(defaultValueRef.value[key]); const isInput = checkIsInput(schema); if (isInput) { + // TODO: 默认值0不生效问题解决 + if (isNumber(defaultValue)) { + return defaultValue; + } return defaultValue || undefined; } if (!defaultValue && schema && checkIsRangeSlider(schema)) {