mengxiong10 / vue2-datepicker

A datepicker / datetimepicker component for Vue2
https://mengxiong10.github.io/vue2-datepicker/index.html
MIT License
1.52k stars 406 forks source link

Is there a way to show only certain months when type="month" #162

Closed vvtense closed 5 years ago

vvtense commented 6 years ago

I have a datepicker with type="month" and range as pictured below

monthpicker

Is there a way to only enable quarter months, i.e.: I only wish to enable:

everything else should be disabled. I cannot figure out how to accomplish this in the current version of vue2-datepicker. Any help would be appreciated, thank you.

mengxiong10 commented 5 years ago

use the disabledDays

<date-picker v-model="value" type="month" :disabledDays="disabledDays" format="YYYY-MM" ></date-picker>
methods: {
    disabledDays (date) {
      const month = new Date(date).getMonth() + 1
      if (month % 3 === 0) {
        return false
      }
      return true
    }
}
vvtense commented 5 years ago

Thank you very much. This is an excellent library, by the way. Very useful and well-made