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

change fixed shortcuts #105

Closed 7ben closed 6 years ago

7ben commented 6 years ago

you know when mounted page, shortcuts is fixed ex) before 1hour => start, end time is current time, but when i will click date-picker input box after 2 hour, this shortcuts is not right i want to change fixed shortcuts when mx-datepicker-popup css changed display plz help me

mengxiong10 commented 6 years ago

I don't fully understand what you mean, can you show your code?

7ben commented 6 years ago

< import DatePicker from 'vue2-datepicker'

export default { components: { DatePicker }, data() { return { time1: '', time2: '', shortcuts: [ { text: 'before 1 hour', start: new Date(Date.now() - 3600 1000 1), end: new Date(Date.now()) } ] } } }

/ if i click shortcuts of before 1 hour after 3hour, date time is not right so i want to change shortcuts when i will click to input box (date-picker) /

mengxiong10 commented 6 years ago

You can listen the change event to change the shortcuts.

<date-picker @change="changeShout"></date-picker>
  methods: {
    changeShortcuts (date) {
      this.shortcuts = [
        {
          text: 'before 1 hour',
          start: new Date(date.getTime() - 3600 * 1000),
          end: new Date(date.getTime())
        }
      ]
    }
  }
7ben commented 6 years ago

thank you