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

Setting a default date range error #71

Open craigwillis85 opened 5 years ago

craigwillis85 commented 5 years ago

I'm trying to set a default date, using the initRange prop, but I'm getting an error.

I have a data property called dateRange

    data: function () {
        return {
            dateRange: {
                'start': '2018-09-14',
                'end': '2018-09-15',
            }
        }
    }

Which I'm passing to the component:

<vue-rangedate-picker @selected="onDateSelected" i18n="EN" righttoleft="false" initRange="dateRange"></vue-rangedate-picker>

But this is throwing the following error:

[Vue warn]: Invalid prop: type check failed for prop "initRange". Expected Object, got String.

This is odd, since the prop I'm passing is an object, unless I'm mistaken?

mediavariance commented 5 years ago

I believe your initRange needs to be prefixed with a colon: <vue-rangedate-picker @selected="onDateSelected" i18n="EN" :righttoleft="false" :initRange="dateRange"></vue-rangedate-picker>

kiasyn commented 5 years ago

using :init-range worked for me

craigwillis85 commented 5 years ago

using :init-range worked for me

Unfortunately, this hasn't worked either. I still don't see any default values in the datepicker

kiasyn commented 5 years ago

ah, I may be using the winslow fork... https://github.com/gwindes/vue-rangedate-picker-winslow

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 } }