refactor(Tabbar): refactor with composition api
This commit is contained in:
@@ -48,6 +48,7 @@ export default createComponent({
|
||||
const [visible, setVisible] = useToggle();
|
||||
const daysRef = ref();
|
||||
const monthRef = ref();
|
||||
const height = useHeight(monthRef);
|
||||
|
||||
const title = computed(() => formatMonthTitle(props.date));
|
||||
|
||||
@@ -82,14 +83,6 @@ export default createComponent({
|
||||
}
|
||||
});
|
||||
|
||||
let height;
|
||||
const getHeight = () => {
|
||||
if (!height) {
|
||||
height = useHeight(monthRef);
|
||||
}
|
||||
return height;
|
||||
};
|
||||
|
||||
const getDate = () => props.data;
|
||||
|
||||
const getTitle = () => title.value;
|
||||
@@ -255,9 +248,9 @@ export default createComponent({
|
||||
|
||||
// @exposed-api
|
||||
const vm = getCurrentInstance().proxy;
|
||||
vm.height = height;
|
||||
vm.getDate = getDate;
|
||||
vm.getTitle = getTitle;
|
||||
vm.getHeight = getHeight;
|
||||
vm.setVisible = setVisible;
|
||||
vm.scrollIntoView = scrollIntoView;
|
||||
|
||||
|
||||
@@ -251,7 +251,9 @@ export default createComponent({
|
||||
const { body } = this.$refs;
|
||||
const { months, monthRefs } = this;
|
||||
const top = getScrollTop(body);
|
||||
const heights = months.map((item, index) => monthRefs[index].getHeight());
|
||||
const heights = months.map(
|
||||
(item, index) => monthRefs[index].height.value
|
||||
);
|
||||
const heightSum = heights.reduce((a, b) => a + b, 0);
|
||||
|
||||
// iOS scroll bounce may exceed the range
|
||||
|
||||
Reference in New Issue
Block a user