mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: improve useHeight (#10197)
This commit is contained in:
parent
32aaed02db
commit
0de7b9c0b9
@ -4,14 +4,14 @@ 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>();
|
||||||
|
|
||||||
|
const setHeight = () => {
|
||||||
|
height.value = useRect(element).height;
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
nextTick(() => {
|
nextTick(setHeight);
|
||||||
height.value = useRect(element).height;
|
|
||||||
});
|
|
||||||
// https://github.com/youzan/vant/issues/10131
|
// https://github.com/youzan/vant/issues/10131
|
||||||
setTimeout(() => {
|
setTimeout(setHeight, 100);
|
||||||
height.value = useRect(element).height;
|
|
||||||
}, 100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user