mengxiong10 / vue2-datepicker

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

Cannot set the dynamic value for the date #687

Closed jjllppp closed 2 years ago

jjllppp commented 2 years ago

It does not show the date that has been save into the database. (for edit)

<date-picker class="wide-date" v-model="time" type="datetime" format="YYYY-MM-DD HH:mm" @input="selecttime" >

export default { data(){ time:new Date(this.data.time), }, created(){ this.getData(); }, methods:{ getData(){ this.sendHttp(/api/data/${this.data}) .then((response) => { this.data = response.data; this.time = moment(this.data.time).format("YYYY-MM-DD HH:mm"); }) .catch((error) => { console.log(error); }) }, }, } the image show the time saved in the database

image

it does not highlighted the date selected in the panel. For example, it should be highlighted the the date 2022-02-11 00:00 that had been saved in the database.

image
mengxiong10 commented 2 years ago

this.time should be a Date not String.

// this.time = moment(this.data.time).format("YYYY-MM-DD HH:mm")
// replace
this.time = new Date(this.data.time)