vant/src/composables/use-height.ts
neverland 0b68d3a141
types: improve ref typing (#8124)
* types: improve ref typing

* types: message
2021-02-10 20:57:24 +08:00

15 lines
322 B
TypeScript

import { useRect } from '@vant/use';
import { Ref, ref, onMounted, nextTick } from 'vue';
export const useHeight = (element: Element | Ref<Element | undefined>) => {
const height = ref<number>();
onMounted(() => {
nextTick(() => {
height.value = useRect(element).height;
});
});
return height;
};