czcaiwj/calendar

dayClick事件怎样判断选中的日期在当前月历中是本月还是上或下个月的

RockYuan opened this issue · 1 comments

image

在5月月历中点6月1日,设置选中日子样式时怎样设置月份是当前,上月还是下月的?

好吧,自已来判断吧

// 判断选中日期是本月,上月还是下月
  dayOnMonth : function(month){
    let dayOnMonth = 'current'

    if (this.data.month == 1 && month == 12) {
      dayOnMonth = 'prev'
    }
    else if (this.data.month == 12 && month == 1) {
      dayOnMonth = 'next'
    }
    else if (month > this.data.month) {
      dayOnMonth = 'next'
    }
    else if (month < this.data.month) {
      dayOnMonth = 'prev'
    }

    return dayOnMonth
  }