theroozbeh / vue2-persian-datepicker

A vue component that provides datepicker for persian developers
MIT License
99 stars 18 forks source link

How Get selected date #17

Closed mariajhn closed 6 years ago

mariajhn commented 6 years ago

Hi, I want to use your datepicker, but I want to extract year, month and day from the selected date. Could you please help me?!

Thnks

theroozbeh commented 6 years ago

Unfortunately it is not possible right now. For the time being you can split selected date with '/' But this feature will be added.

theroozbeh commented 6 years ago

Upgrade to latest version. Now you can listen to selected event, and use it's input parameter for getting year, month and day.

theroozbeh commented 6 years ago

Try this fiddle: https://jsfiddle.net/rh2020/zjezzfdk/

mariajhn commented 6 years ago

Many thanks for your reply. When I run this code, the output is repeated three times in console !!!! Isn't possible to use year, month or day as below: {{date.year}} But, I have another question, I want to write this code when a date is selected: v-on:selected="visitDate=date" where myDate is a variable in a controller. Is it possible?

theroozbeh commented 6 years ago

Yes it is possible. Use parentheses function definition. v-on:selected="(date) => {this.visitDate = date;}"