I have an input like so:
<input class="input" type="date" v-model="dob" />
dob
is initialized as null, and works properly. For example 03/05/2006 models to 2006-03-05T00:00:00.000+00:0
. However when dob
is inititialized as 2006-03-05T00:00:00.000+00:0
, it doesn't show in the date input. How would I fix this.
EDIT: you could use to set a default value and have it changing afterwards.
data() {
return {
initialDate: Date.now(),
};
},
computed: {
dob: {
get() {
return this.initialDate;
},
set(newValue) {
this.initialDate = newValue;
},
},
},
Where is your input coming from? It probably needs a UNIX timestamp like 1612454883231
. Try initializing it with Date.now()
or maybe try new Date().toISOString().slice(0,10)
.
Also, new Date('2006-03-05T00:00:00')
if you want to set it manually (and since it's a date of birth...).
If it doesn't work, you need to dig the documentation to see which format it accepts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.