feat(Calendar): add show-subtitle prop (#5779)

This commit is contained in:
chenjiahan
2020-03-09 20:55:20 +08:00
parent e575bb4bb1
commit 17ecc980a7
9 changed files with 64 additions and 23 deletions
+10 -9
View File
@@ -6,22 +6,23 @@ const [createComponent] = createNamespace('calendar-header');
export default createComponent({
props: {
title: String,
subtitle: String,
showTitle: Boolean,
monthTitle: String,
showSubtitle: Boolean,
},
methods: {
genTitle() {
if (!this.showTitle) {
return;
if (this.showTitle) {
const title = this.slots('title') || this.title || t('title');
return <div class={bem('header-title')}>{title}</div>;
}
const title = this.slots('title') || this.title || t('title');
return <div class={bem('header-title')}>{title}</div>;
},
genMonth() {
return <div class={bem('month-title')}>{this.monthTitle}</div>;
genSubtitle() {
if (this.showSubtitle) {
return <div class={bem('header-subtitle')}>{this.subtitle}</div>;
}
},
genWeekDays() {
@@ -41,7 +42,7 @@ export default createComponent({
return (
<div class={bem('header')}>
{this.genTitle()}
{this.genMonth()}
{this.genSubtitle()}
{this.genWeekDays()}
</div>
);