mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(Calendar): show first month title when subtitle is hidden
This commit is contained in:
parent
17ecc980a7
commit
885a9e6ac7
@ -20,10 +20,11 @@ export default createComponent({
|
|||||||
minDate: Date,
|
minDate: Date,
|
||||||
maxDate: Date,
|
maxDate: Date,
|
||||||
showMark: Boolean,
|
showMark: Boolean,
|
||||||
showTitle: Boolean,
|
|
||||||
rowHeight: [Number, String],
|
rowHeight: [Number, String],
|
||||||
formatter: Function,
|
formatter: Function,
|
||||||
currentDate: [Date, Array],
|
currentDate: [Date, Array],
|
||||||
|
showSubtitle: Boolean,
|
||||||
|
showMonthTitle: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -89,7 +90,11 @@ export default createComponent({
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
scrollIntoView() {
|
scrollIntoView() {
|
||||||
this.$refs.days.scrollIntoView();
|
if (this.showSubtitle) {
|
||||||
|
this.$refs.days.scrollIntoView();
|
||||||
|
} else {
|
||||||
|
this.$refs.month.scrollIntoView();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getMultipleDayType(day) {
|
getMultipleDayType(day) {
|
||||||
@ -202,7 +207,7 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
genTitle() {
|
genTitle() {
|
||||||
if (this.showTitle) {
|
if (this.showMonthTitle) {
|
||||||
return <div class={bem('month-title')}>{this.title}</div>;
|
return <div class={bem('month-title')}>{this.title}</div>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -279,7 +284,7 @@ export default createComponent({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class={bem('month')} style={this.monthStyle}>
|
<div class={bem('month')} ref="month" style={this.monthStyle}>
|
||||||
{this.genTitle()}
|
{this.genTitle()}
|
||||||
{this.genDays()}
|
{this.genDays()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -327,6 +327,7 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
genMonth(date, index) {
|
genMonth(date, index) {
|
||||||
|
const showMonthTitle = index !== 0 || !this.showSubtitle;
|
||||||
return (
|
return (
|
||||||
<Month
|
<Month
|
||||||
ref="months"
|
ref="months"
|
||||||
@ -339,8 +340,9 @@ export default createComponent({
|
|||||||
showMark={this.showMark}
|
showMark={this.showMark}
|
||||||
formatter={this.formatter}
|
formatter={this.formatter}
|
||||||
rowHeight={this.rowHeight}
|
rowHeight={this.rowHeight}
|
||||||
showTitle={index !== 0}
|
|
||||||
currentDate={this.currentDate}
|
currentDate={this.currentDate}
|
||||||
|
showSubtitle={this.showSubtitle}
|
||||||
|
showMonthTitle={showMonthTitle}
|
||||||
onClick={this.onClickDay}
|
onClick={this.onClickDay}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user