mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +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>) => {
|
||||
const height = ref<number>();
|
||||
|
||||
onMounted(() =>
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
height.value = useRect(element).height;
|
||||
})
|
||||
);
|
||||
});
|
||||
// https://github.com/youzan/vant/issues/10131
|
||||
setTimeout(() => {
|
||||
height.value = useRect(element).height;
|
||||
}, 100);
|
||||
});
|
||||
|
||||
return height;
|
||||
};
|
||||
|
Reference in New Issue
Block a user