From 617e594d8de94090ced7c7d2b9fb805ad42dcb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=98=BF=E6=96=87?= <1052642137@qq.com> Date: Thu, 8 Aug 2024 20:50:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(form):=20=E4=BD=BF=E7=94=A8=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E5=90=88=E5=B9=B6=E8=BF=90=E7=AE=97=E7=AC=A6=20(=3F?= =?UTF-8?q?=3F)=20=E5=92=8C=20isDef=20=E4=BC=98=E5=8C=96=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A4=84=E7=90=86?= =?UTF-8?q?=20labelWidth=20=E5=8F=AF=E8=83=BD=E4=B8=BA=200=20=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=20(#4086)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/hooks/useLabelWidth.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Form/src/hooks/useLabelWidth.ts b/src/components/Form/src/hooks/useLabelWidth.ts index 511ba42c..ef197823 100644 --- a/src/components/Form/src/hooks/useLabelWidth.ts +++ b/src/components/Form/src/hooks/useLabelWidth.ts @@ -1,7 +1,7 @@ import type { Ref } from 'vue'; import { computed, unref } from 'vue'; import type { FormProps, FormSchemaInner as FormSchema } from '../types/form'; -import { isNumber } from '@/utils/is'; +import { isDef, isNumber } from '@/utils/is'; export function useItemLabelWidth(schemaItemRef: Ref, propsRef: Ref) { return computed(() => { @@ -23,11 +23,11 @@ export function useItemLabelWidth(schemaItemRef: Ref, propsRef: Ref< }; return { labelCol, wrapperCol }; } - let width = labelWidth || globalLabelWidth; + let width = labelWidth ?? globalLabelWidth; const col = { ...globalLabelCol, ...labelCol }; const wrapCol = { ...globWrapperCol, ...wrapperCol }; - if (width) { + if (isDef(width)) { width = isNumber(width) ? `${width}px` : width; }