From 885a9e6ac7a7f0aa851e9eb31043cdf18b8472ca Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 9 Mar 2020 23:08:15 +0800 Subject: [PATCH] chore(Calendar): show first month title when subtitle is hidden --- src/calendar/components/Month.js | 13 +++++++++---- src/calendar/index.js | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/calendar/components/Month.js b/src/calendar/components/Month.js index 7bbdc38cf..05d6ad792 100644 --- a/src/calendar/components/Month.js +++ b/src/calendar/components/Month.js @@ -20,10 +20,11 @@ export default createComponent({ minDate: Date, maxDate: Date, showMark: Boolean, - showTitle: Boolean, rowHeight: [Number, String], formatter: Function, currentDate: [Date, Array], + showSubtitle: Boolean, + showMonthTitle: Boolean, }, data() { @@ -89,7 +90,11 @@ export default createComponent({ methods: { scrollIntoView() { - this.$refs.days.scrollIntoView(); + if (this.showSubtitle) { + this.$refs.days.scrollIntoView(); + } else { + this.$refs.month.scrollIntoView(); + } }, getMultipleDayType(day) { @@ -202,7 +207,7 @@ export default createComponent({ }, genTitle() { - if (this.showTitle) { + if (this.showMonthTitle) { return
{this.title}
; } }, @@ -279,7 +284,7 @@ export default createComponent({ render() { return ( -
+
{this.genTitle()} {this.genDays()}
diff --git a/src/calendar/index.js b/src/calendar/index.js index c1f20ff7e..468da160b 100644 --- a/src/calendar/index.js +++ b/src/calendar/index.js @@ -327,6 +327,7 @@ export default createComponent({ }, genMonth(date, index) { + const showMonthTitle = index !== 0 || !this.showSubtitle; return ( );