2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-08 19:02:28 +03:00

feat: add event 'change-calendar-year' 'change-calendar-month'

This commit is contained in:
mxie
2018-08-06 12:07:04 +08:00
parent 6ecfed8734
commit bc80708787
+22 -2
View File
@@ -290,14 +290,34 @@ export default {
changeCalendarMonth (month) {
this.now = new Date(this.calendarYear, month)
},
getSibling () {
const calendars = this.$parent.$children.filter(v => v.$options.name === this.$options.name)
const index = calendars.indexOf(this)
const sibling = calendars[index ^ 1]
return sibling
},
handleIconMonth (flag) {
this.changeCalendarMonth(this.calendarMonth + flag)
const month = this.calendarMonth
this.changeCalendarMonth(month + flag)
this.$parent.$emit('change-calendar-month', {
month,
flag,
vm: this,
sibling: this.getSibling()
})
},
handleIconYear (flag) {
if (this.panel === 'YEAR') {
this.changePanelYears(flag)
} else {
this.changeCalendarYear(this.calendarYear + flag)
const year = this.calendarYear
this.changeCalendarYear(year + flag)
this.$parent.$emit('change-calendar-year', {
year,
flag,
vm: this,
sibling: this.getSibling()
})
}
},
handleBtnYear () {