mengxiong10 / vue2-datepicker

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

Using DatePicker as a birthday picker #174

Closed alataknet closed 6 years ago

alataknet commented 6 years ago

Hello How to use vue2-datepicker as a birthday picker, ie: the order of the panels would be Year, Month, and then day ?

mengxiong10 commented 6 years ago

You need to change the source code.


import DatePicker from 'vue2-datepicker'

const init = DatePicker.components.CalendarPanel.methods.init

DatePicker.components.CalendarPanel.methods.init = function () {
  init.call(this)
  this.panel = 'YEAR'
}
alataknet commented 6 years ago

Hello, Thank you. I use the date picker also as a normal date picker. I tried with Vue.nextTick, but I did not find the correct way of doing it

mengxiong10 commented 6 years ago

In V2.5.0.

'<date-picker ref="date" @panel-change="handlePanelChange" v-model="value" lang="en" ></date-picker>'
  methods: {
    handlePanelChange (panel, oldPanel) {
      if (oldPanel === 'NONE') {
        this.$refs.date.$children[0].panel = 'YEAR'
      }
    }
  }
alataknet commented 6 years ago

Thank you very much. Works perfect