mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
chore(Calendar): show first month title when subtitle is hidden
This commit is contained in:
@@ -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 <div class={bem('month-title')}>{this.title}</div>;
|
||||
}
|
||||
},
|
||||
@@ -279,7 +284,7 @@ export default createComponent({
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div class={bem('month')} style={this.monthStyle}>
|
||||
<div class={bem('month')} ref="month" style={this.monthStyle}>
|
||||
{this.genTitle()}
|
||||
{this.genDays()}
|
||||
</div>
|
||||
|
@@ -327,6 +327,7 @@ export default createComponent({
|
||||
},
|
||||
|
||||
genMonth(date, index) {
|
||||
const showMonthTitle = index !== 0 || !this.showSubtitle;
|
||||
return (
|
||||
<Month
|
||||
ref="months"
|
||||
@@ -339,8 +340,9 @@ export default createComponent({
|
||||
showMark={this.showMark}
|
||||
formatter={this.formatter}
|
||||
rowHeight={this.rowHeight}
|
||||
showTitle={index !== 0}
|
||||
currentDate={this.currentDate}
|
||||
showSubtitle={this.showSubtitle}
|
||||
showMonthTitle={showMonthTitle}
|
||||
onClick={this.onClickDay}
|
||||
/>
|
||||
);
|
||||
|
Reference in New Issue
Block a user