Comments (7)
Hi @mohammadfiroozi
the new version is published and I add the setDate
method for your problem.
<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.
from vue-persian-datepicker.
@honarmanly Yes. it's right. I fix it.
thanks
from vue-persian-datepicker.
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"]
}
}
}
from vue-persian-datepicker.
this not working when i set it in created life cycle or other method,
<date-picker v-model="formValues.birthDate" mode="single"></date-picker>
`
created() {
this.formValues= {
nationalCode: this.nationalCode,
birthDate: "2021/05/12"
};
}
`
from vue-persian-datepicker.
The data model must be filled before the component is mounted.
I suggest using beforeMount
to set the data model.
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.
from vue-persian-datepicker.
$ref is not defined in created phase, but I used it in mounted and it works
from vue-persian-datepicker.
@honarmanly
Yes. it's right. I fix it.
from vue-persian-datepicker.
Related Issues (20)
- select just year or month HOT 2
- nuxt app crashes while in ssr mode and page scroll occurs HOT 2
- Features needed HOT 2
- get display value HOT 3
- clear button and set manually HOT 4
- warning در ناکست HOT 2
- set default value
- Bug with the new version HOT 2
- مشکل کار با localconfig HOT 1
- custom attributes HOT 4
- disable date rang HOT 2
- turbolinks and datepicker HOT 1
- how set initial value HOT 1
- selection-range ساخت تابع برای HOT 2
- تنظیم مقدار پیش فرض ساعت HOT 10
- ست كردن تاريخ جهت نمايش HOT 1
- نمایش تاریخ شمسی به جای تاریخ میلادی HOT 1
- Get Date
- multi select HOT 1
- ایجاد فیلد الزامی HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-persian-datepicker.