diff --git a/src/calendar/components/Month.js b/src/calendar/components/Month.js index 2703fbec1..50280034f 100644 --- a/src/calendar/components/Month.js +++ b/src/calendar/components/Month.js @@ -90,11 +90,14 @@ export default createComponent({ }, }, - mounted() { - this.height = this.$el.getBoundingClientRect().height; - }, - methods: { + getHeight() { + if (!this.height) { + this.height = this.$el.getBoundingClientRect().height; + } + return this.height; + }, + scrollIntoView() { if (this.showSubtitle) { this.$refs.days.scrollIntoView(); diff --git a/src/calendar/index.js b/src/calendar/index.js index 1fa30530e..e05b3a13a 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -234,7 +234,7 @@ export default createComponent({ const { body, months } = this.$refs; const top = getScrollTop(body); const bottom = top + this.bodyHeight; - const heights = months.map((item) => item.height); + const heights = months.map((item) => item.getHeight()); const heightSum = heights.reduce((a, b) => a + b, 0); // iOS scroll bounce may exceed the range