From 38a4f02acdbccda07f6eaada58a8b9cd32b0b22a Mon Sep 17 00:00:00 2001 From: markon1 Date: Tue, 20 Nov 2018 13:16:03 +0100 Subject: [PATCH] prevMonthPreview and nextMonthPreview can go into next year now --- src/Datepicker.vue | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Datepicker.vue b/src/Datepicker.vue index 8fa2d8e..9571211 100644 --- a/src/Datepicker.vue +++ b/src/Datepicker.vue @@ -196,11 +196,21 @@ this.yearList = this.yearList.map((i) => i - 12) } }, - prevMonthPreview () { - this.tmpMonth = this.tmpMonth === 0 ? 0 : this.tmpMonth - 1 - }, - nextMonthPreview () { - this.tmpMonth = this.tmpMonth === 11 ? 11 : this.tmpMonth + 1 + prevMonthPreview() { + if (this.tmpMonth === 0) { + this.tmpMonth = 11; + this.tmpYear = this.tmpYear - 1; + } else { + this.tmpMonth = this.tmpMonth - 1; + } + }, + nextMonthPreview() { + if (this.tmpMonth === 11) { + this.tmpMonth = 0; + this.tmpYear = this.tmpYear + 1; + } else { + this.tmpMonth = this.tmpMonth + 1; + } }, selectYear (year) { if(this.validateYear(year)) return