ankurk91 / vue-bootstrap-datetimepicker

Vue.js component for eonasdan bootstrap datetimepicker
MIT License
223 stars 66 forks source link

change config options in computed not work #10

Closed ymps3502 closed 7 years ago

ymps3502 commented 7 years ago

I want to make date range with date-picker, so I have two date-picker in my template. I can see config change in vue-devtools, but it dose not work on date-picker. I still can pick any date without restrictions. Here's my code:

/*in template*/
<datePicker v-model="dateStart" :config="dateStartConfig"></datePicker>
<datePicker v-model="dateEnd" :config="dateEndConfig"></datePicker>

/*in script*/
data() {
    return {
        Start: new Date(),
        End: new Date(),
        dateStartConfig: {
            minDate: '2000-01-01',
            maxDate: new Date()
        },
        dateEndConfig: {
            minDate: '2000-01-01',
            maxDate: new Date()
        }
    }
},
computed: {
    dateStart: {
        get() {
            return this.Start
        },
        set(value) {
            this.Start = value
            this.dateEndConfig.minDate = moment(value).format('Y-M-D'))
        }
    },
    dateEnd: {
        get() {
            return this.End
            // return this.$store.state.order.dateEnd
        },
        set(value) {
            this.End = value
            this.dateStartConfig.maxDate = moment(value).format('Y-M-D')
        }
    }
}
ankurk91 commented 7 years ago

https://github.com/ankurk91/vue-bootstrap-datetimepicker/blob/3a6c8a6c6aed6d85abd824b69c2c63f6b0f4db28/examples/App.vue#L225-L237