bliblidotcom / vue-rangedate-picker

Range date picker with simple usage
https://bliblidotcom.github.io/vue-rangedate-picker/demo/
MIT License
218 stars 123 forks source link

Initial Select range date #44

Open aepsaepudin94 opened 6 years ago

aepsaepudin94 commented 6 years ago

How i can initialize selected date ?

joethekurian commented 6 years ago

Initialise value to dateRange Object (rangedate-picker.js)

apiep commented 6 years ago

I don't know why, but this commit https://github.com/bliblidotcom/vue-rangedate-picker/commit/77cf9836f96d389dc8ea1da41cb84fe627e0d085 remove this functionality (Set initial value)

Denis4yk commented 6 years ago

Any progress on this?

MrSnoozles commented 6 years ago

Same, this feature is not in the code base anymore, but still in the documentation. Is there any progress on this?

wujinfeng commented 6 years ago

No progress ? this.dateRange = this.initRange,why remove it? How initialize selected date ?

AndersSchmidtHansen commented 6 years ago

Had a similar issue. A temporary fix that worked for me was to add a "ref" to the rangedate-picker element and then adding the following in a mounted() hook:

  mounted () {
    this.$refs.rangeDatePicker.dateRange = {
      start: new Date(this.initRange.start),
      end: new Date(this.initRange.end)
    }
  }

In my case, the initial initRange object was like this:

{
   'start': '2018-05-14T22:00:00.000Z',
   'end': '2018-05-15T21:59:00.000Z'
}
skillnull commented 6 years ago

借助楼上的说法,看了一眼源码,正确的initRange应该是这样的(这里用的是近7天): initRange: { 'start': new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 5, 0, 0), 'end': new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1, 0, 0) } 文档写的也真是太简陋了...

jinfeicheng commented 5 years ago

It's worked for me. Try like this: Use this forked version instead of the origin version. https://github.com/gwindes/vue-rangedate-picker-winslow (this week as default ) <vue-rangedate-picker :initRange="datePickerConfig.initRange" const datePickerConfig = { initRange: { start: moment().startOf('week').add(2,'days')._d, end: moment().startOf('week').add(8,'days')._d } }

bagaskarawg commented 5 years ago

Had a similar issue. A temporary fix that worked for me was to add a "ref" to the rangedate-picker element and then adding the following in a mounted() hook:

  mounted () {
    this.$refs.rangeDatePicker.dateRange = {
      start: new Date(this.initRange.start),
      end: new Date(this.initRange.end)
    }
  }

In my case, the initial initRange object was like this:

{
   'start': '2018-05-14T22:00:00.000Z',
   'end': '2018-05-15T21:59:00.000Z'
}

This feature should've been available, though thanks to @AndersSchmidtHansen's trick, it all goes well!