From 987102260cf30279306914075b3f82b6083d4406 Mon Sep 17 00:00:00 2001 From: liyang Date: Thu, 30 Dec 2021 20:00:19 +0800 Subject: [PATCH] fix(ui/menu): modify the implementation of sloving offsetHeight error --- packages/varlet-ui/src/menu/Menu.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/varlet-ui/src/menu/Menu.vue b/packages/varlet-ui/src/menu/Menu.vue index 4fe74bf4266..bf63a260dbe 100644 --- a/packages/varlet-ui/src/menu/Menu.vue +++ b/packages/varlet-ui/src/menu/Menu.vue @@ -67,10 +67,8 @@ export default defineComponent({ // expose const resize = () => { - nextTick(() => { - top.value = computeTop(props.alignment) - left.value = getLeft(host.value as HTMLElement) - }) + top.value = computeTop(props.alignment) + left.value = getLeft(host.value as HTMLElement) } watch(() => props.alignment, resize) @@ -79,7 +77,10 @@ export default defineComponent({ () => props.show, async (newValue: boolean) => { const { onOpen, onClose } = props - newValue && resize() + if (newValue) { + await nextTick() + resize() + } newValue ? onOpen?.() : onClose?.() } )