UNPKG

press-next

Version:

Vue3 组件库,支持 Composition API

34 lines (23 loc) 635 B
import { ref, computed, onBeforeMount } from 'vue'; import { getStatusBarHeight } from '../../common/utils/status-bar-height'; export function useStatusBarHeight() { const statusBarHeight = ref(20); const headerHeight = computed(() => statusBarHeight.value + 44); const headerHeightStyle = computed(() => `height: ${headerHeight.value}px`); const init = () => { getStatusBarHeight() .then((res) => { statusBarHeight.value = res; }) .catch(() => {}); }; init(); onBeforeMount(() => { init(); }); return { statusBarHeight, headerHeight, headerHeightStyle, }; }