refactor(Tabbar): refactor with composition api

This commit is contained in:
chenjiahan
2020-08-28 15:19:16 +08:00
parent e3cf460762
commit f843e6def9
7 changed files with 117 additions and 132 deletions
+9 -3
View File
@@ -1,7 +1,13 @@
import type { Ref } from 'vue';
import { Ref, ref, onMounted } from 'vue';
export const useRect = (el: Ref<Element>) => el.value.getBoundingClientRect();
export const useWidth = (el: Ref<Element>) => useRect(el).width;
export const useHeight = (el: Ref<Element>) => {
const height = ref();
export const useHeight = (el: Ref<Element>) => useRect(el).height;
onMounted(() => {
height.value = useRect(el).height;
});
return height;
};