From 89fdbf4729bf9c3198eb11d3d53448ecef29917f Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 7 Jul 2020 14:44:20 +0800 Subject: [PATCH] fix(Calendar): subtitle not updated in some cases (#6723) --- src/calendar/components/Month.js | 11 +++++++---- src/calendar/index.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) 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