I'm trying to follow this video using Vue and Vuetify to apply the current date with v-model
to the date picker component v-date-picker
using the data value date
that's initially being set with new Date()
.
This is a simplified structure of my project:
JS
new Vue({
el:"#app",
data: {
date: new Date(),
time: new Date()
}
})
Template
<div id="app">
<v-date-picker v-model="date"></v-date-picker>
{{ date }}
<v-time-picker v-model="time"></v-time-picker>
</div>
And here's a CodePen. Unfortunately I couldn't get the Vuetify CSS to work with the CodePen, but if you open up the console, you'll see that I get errors in the v-date-picker
when trying to use new Date()
with the v-model
directive. Also the date picker isn't rendering. The v-time-picker
however works fine.
On my local setup I've created a Vue project with the vue-cli. Here's the error I'm getting there:
[Vue warn]: Error in created hook: "TypeError: dateString.split is not a function"
found in
---> at src/components/Meetup/CreateMeetup.vue at src/App.vue
I'm doing exactly as in the tutorial I'm following, so I don't know if this is a bug with the latest version of either Vue or Vuetify? Or am I missing something?
data: { date: new Date().toJSON(), time: new Date().toJSON() }
– connexonew Date()
outputting a string? – tobiasgDate
object. – connexov-date-picker
andv-time-picker
expects different types? – tobiasgString
. – connexo