Skip to content

Commit

Permalink
feat: add event 'change-calendar-year' 'change-calendar-month'
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Aug 6, 2018
1 parent 6ecfed8 commit bc80708
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit bc80708

Please sign in to comment.