mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 16:04:04 +00:00
fix: useHeight may get the wrong height (#10195)
This commit is contained in:
@@ -4,11 +4,15 @@ import { Ref, ref, onMounted, nextTick } from 'vue';
|
|||||||
export const useHeight = (element: Element | Ref<Element | undefined>) => {
|
export const useHeight = (element: Element | Ref<Element | undefined>) => {
|
||||||
const height = ref<number>();
|
const height = ref<number>();
|
||||||
|
|
||||||
onMounted(() =>
|
onMounted(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
height.value = useRect(element).height;
|
height.value = useRect(element).height;
|
||||||
})
|
});
|
||||||
);
|
// https://github.com/youzan/vant/issues/10131
|
||||||
|
setTimeout(() => {
|
||||||
|
height.value = useRect(element).height;
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user