-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to set date to datepicker ? #4
Comments
In single mode use string and in range mode use array. (date must be gregorian) <date-picker v-model="date" mode="single"></date-picker> export default {
data() {
return {
date: "2021/05/12"
}
}
} <date-picker v-model="date" mode="range"></date-picker> export default {
data() {
return {
date: ["2021/05/12", "2021/05/15"]
}
}
} |
this not working when i set it in created life cycle or other method,
` this.formValues= { } |
The data model must be filled before the component is mounted. If you can not set the data model before mount, use this way: <date-picker v-model="date" mode="single" ref="dp"></date-picker> import { PersianDate } from "@alireza-ab/vue-persian-datepicker"
export default {
data() {
return {
date: null
}
},
created(){
this.$refs.dp.selectDate(new PersianDate("2021/5/12"), "date");
}
} In the next version, I add a better way to set the data model. |
Hi @mohammadfiroozi <date-picker v-model="date" mode="single" ref="dp"></date-picker> export default {
data() {
return {
date: null
}
},
mounted(){
this.$refs.dp.setDate("2021/5/12");
}
} I suggest setting the data model before the component is mounted. use this way, after the component is mounted. |
$ref is not defined in created phase, but I used it in mounted and it works |
@honarmanly |
thanks |
how to set date from data model to datepicker and show it in datepicker?
The text was updated successfully, but these errors were encountered: