Skip to content

Commit

Permalink
[F] 切换年月时因类型问题导致计算可能出错
Browse files Browse the repository at this point in the history
  • Loading branch information
付登荣 committed Jun 21, 2019
1 parent 6bd2d2d commit 37bda4e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/component/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ Component({
chooseYear(type) {
const { curYear, curMonth } = this.data.calendar;
if (!curYear || !curMonth) return warn('异常:未获取到当前年月');
let newYear = curYear;
let newMonth = curMonth;
let newYear = +curYear;
let newMonth = +curMonth;
if (type === 'prev_year') {
newYear = curYear - 1;
newYear = +curYear - 1;
} else if (type === 'next_year') {
newYear = curYear + 1;
newYear = +curYear + 1;
}
this.calculate(curYear, curMonth, newYear, newMonth);
},
chooseMonth(type) {
const { curYear, curMonth } = this.data.calendar;
if (!curYear || !curMonth) return warn('异常:未获取到当前年月');
let newYear = curYear;
let newMonth = curMonth;
let newYear = +curYear;
let newMonth = +curMonth;
if (type === 'prev_month') {
newMonth = curMonth - 1;
newMonth = +curMonth - 1;
if (newMonth < 1) {
newYear = curYear - 1;
newYear = +curYear - 1;
newMonth = 12;
}
} else if (type === 'next_month') {
newMonth = curMonth + 1;
newMonth = +curMonth + 1;
if (newMonth > 12) {
newYear = curYear + 1;
newYear = +curYear + 1;
newMonth = 1;
}
}
Expand Down

0 comments on commit 37bda4e

Please sign in to comment.