From 53d69b3e3aefee6600978edb8360723a13c574b6 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Wed, 9 Sep 2020 10:00:05 +0800 Subject: [PATCH] fix: use-rect add nextTick --- src/composition/use-rect.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/composition/use-rect.ts b/src/composition/use-rect.ts index 1dedbe4d1..48ebec2fb 100644 --- a/src/composition/use-rect.ts +++ b/src/composition/use-rect.ts @@ -1,4 +1,4 @@ -import { Ref, ref, onMounted } from 'vue'; +import { Ref, ref, onMounted, nextTick } from 'vue'; export const useRect = (el: Ref) => el.value.getBoundingClientRect(); @@ -6,7 +6,9 @@ export const useHeight = (el: Ref) => { const height = ref(); onMounted(() => { - height.value = useRect(el).height; + nextTick(() => { + height.value = useRect(el).height; + }); }); return height;