From 32aaed02db411695d173daed4f2a621df715c4ef Mon Sep 17 00:00:00 2001 From: yuhengshen Date: Sun, 16 Jan 2022 16:28:31 +0800 Subject: [PATCH] fix: useHeight may get the wrong height (#10195) --- packages/vant/src/composables/use-height.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/vant/src/composables/use-height.ts b/packages/vant/src/composables/use-height.ts index 487f521de..dec59831d 100644 --- a/packages/vant/src/composables/use-height.ts +++ b/packages/vant/src/composables/use-height.ts @@ -4,11 +4,15 @@ import { Ref, ref, onMounted, nextTick } from 'vue'; export const useHeight = (element: Element | Ref) => { const height = ref(); - onMounted(() => + onMounted(() => { nextTick(() => { height.value = useRect(element).height; - }) - ); + }); + // https://github.com/youzan/vant/issues/10131 + setTimeout(() => { + height.value = useRect(element).height; + }, 100); + }); return height; };