alireza-ab / vue3-persian-datepicker

A datepicker component for select date (vue 3)
MIT License
34 stars 2 forks source link

Two-way binding #9

Closed hamedg68 closed 7 months ago

hamedg68 commented 9 months ago

If I want to change the v-model from out of the component, for example If the date gotten from the server, the date does not set on model-value, I think it needs to track the external changes of model-value with watch.

alireza-ab commented 9 months ago

Hi @hamedg68 This is the solution: https://github.com/alireza-ab/vue-persian-datepicker/issues/4#issuecomment-847644142 the code example is for vue 2 but you can use it for vue 3.

hamedg68 commented 9 months ago

The concept of using v-model is to use on a component to implement a two-way binding at any time, if we use setDate() for setting new value, actually breaks the concept of using v-model and we can use :modelValue instead of v-model. https://vuejs.org/guide/components/v-model.html I have solved this issue on pull request

alireza-ab commented 9 months ago

You're right. I had done this wrong from the start and didn't change it. but about your PR, did you run the test cases? I run test cases and it doesn't run correctly. Also, you change the package.json file in your PR.