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; }