diff --git a/packages/components/dialog/src/use-dialog.ts b/packages/components/dialog/src/use-dialog.ts index 3da94bbc8c741..14533eb18bf3c 100644 --- a/packages/components/dialog/src/use-dialog.ts +++ b/packages/components/dialog/src/use-dialog.ts @@ -16,7 +16,7 @@ import { useZIndex, } from '@element-plus/hooks' import { UPDATE_MODEL_EVENT } from '@element-plus/constants' -import { isNumber } from '@element-plus/utils' +import { addUnit } from '@element-plus/utils' import type { CSSProperties, Ref, SetupContext } from 'vue' import type { DialogEmits, DialogProps } from './dialog' @@ -40,10 +40,6 @@ export const useDialog = ( let openTimer: (() => void) | undefined = undefined let closeTimer: (() => void) | undefined = undefined - const normalizeWidth = computed(() => - isNumber(props.width) ? `${props.width}px` : props.width - ) - const namespace = useGlobalConfig('namespace', defaultNamespace) const style = computed(() => { @@ -54,7 +50,7 @@ export const useDialog = ( style[`${varPrefix}-margin-top`] = props.top } if (props.width) { - style[`${varPrefix}-width`] = normalizeWidth.value + style[`${varPrefix}-width`] = addUnit(props.width) } } return style