bbsimonbb
bbsimonbb

Reputation: 28982

In Vue, how do I bind a date object to a date input ? (v-model doesn't work)

// This doesn't work
<input type='date' v-model='store.myDateObject'>

How can I bind a date input to a date object in my store?

Upvotes: 3

Views: 6050

Answers (1)

bbsimonbb
bbsimonbb

Reputation: 28982

Assuming you want your dates as midnight UTC date objects, do this...

<input type='date'
    :value='store.myDate.toJSON().substring(0,10)'
    @input='store.myDate = new Date($event.target.value)'
>

Upvotes: 5

Related Questions