fix: use-rect add nextTick

This commit is contained in:
chenjiahan 2020-09-09 10:00:05 +08:00
parent fb03ef92c5
commit 53d69b3e3a

View File

@ -1,4 +1,4 @@
import { Ref, ref, onMounted } from 'vue';
import { Ref, ref, onMounted, nextTick } from 'vue';
export const useRect = (el: Ref<Element>) => el.value.getBoundingClientRect();
@ -6,7 +6,9 @@ export const useHeight = (el: Ref<Element>) => {
const height = ref();
onMounted(() => {
height.value = useRect(el).height;
nextTick(() => {
height.value = useRect(el).height;
});
});
return height;