diff --git a/src/calendar/index.js b/src/calendar/index.js index 7838a0581..4015f186d 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -1,4 +1,5 @@ import { isDate } from '../utils/validate/date'; +import { getScrollTop } from '../utils/dom/scroll'; import { createComponent, bem, compareMonth, formatMonthTitle } from './utils'; import Header from './Header'; @@ -42,6 +43,8 @@ export default createComponent({ }, data() { + this.monthsHeight = []; + return { currentMonth: this.minDate }; @@ -69,12 +72,22 @@ export default createComponent({ } }, + mounted() { + this.getMonthsHeight(); + }, + methods: { + getMonthsHeight() { + this.$refs.month.forEach((month, index) => { + this.monthsHeight[index] = month.getBoundingClientRect().height; + }); + }, + genMonth(month, index) { const showTitle = index !== 0; return ( -