mirror of
https://github.com/youzan/vant.git
synced 2025-10-15 23:55:08 +00:00
chore: improve useHeight (#10197)
This commit is contained in:
@@ -4,14 +4,14 @@ import { Ref, ref, onMounted, nextTick } from 'vue';
|
||||
export const useHeight = (element: Element | Ref<Element | undefined>) => {
|
||||
const height = ref<number>();
|
||||
|
||||
const setHeight = () => {
|
||||
height.value = useRect(element).height;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
height.value = useRect(element).height;
|
||||
});
|
||||
nextTick(setHeight);
|
||||
// https://github.com/youzan/vant/issues/10131
|
||||
setTimeout(() => {
|
||||
height.value = useRect(element).height;
|
||||
}, 100);
|
||||
setTimeout(setHeight, 100);
|
||||
});
|
||||
|
||||
return height;
|
||||
|
Reference in New Issue
Block a user