Click here to Skip to main content
15,885,957 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

Hope you have good end year season ?

I am having an issue to use v-model="time" inside the date picker.

When I remove it I get the expected inline date picker but to grab the value and dump it inside the component. Once I v-model to the datepicker tag, it does not want to display it on the page.

Could somebody provide me a hint to cover that issue ? thank you very much in advance.

Also I had to write inline="true" like that and not inline=true to obtain the expected effect. The goal is the be able to dump the selected date on the page via {{time}}.

Thank you very much in advance

Here is the current code in datepicker.vue I am using:

JavaScript
<template>
    <div>

      <datepicker :format="customDate" v-model="time" :inline="true"></datepicker>
      {{time}}
    </div>
</template>
 
<script type="text/javascript">
    import datepicker from 'vuejs-datepicker';
    import moment from 'moment';
 
    export default
    {
        data()
        {
            return
            {
                time:''
            }
        },
        components:
        {
            datepicker  
        },
        methods:
        {
            customDate(date)
            {               
                this.time = moment(date).format('DD-MM-YYYY');
            }
        }
    }
</script>


What I have tried:

<datepicker :format="customDate" :inline="true"></datepicker>
works but without v-model tag, why ???
Posted
Updated 3-Jul-22 17:18pm
v2
Comments
0x01AA 26-Dec-21 8:51am    
Which vue version?
SuperMiQi 26-Dec-21 9:11am    
Hello,
Thank you for your reply,
I am using:
"vuejs-datepicker": "^1.6.2"
"moment": "^2.29.1"
If you need extra inputs, let me know. Thanks in advance. Happy holidays.
SuperMiQi 26-Dec-21 15:30pm    
Do you have an idea ?
Thank you very much in advance.

1 solution

Hi.. I have tried so many things. Please use :value instead of v-model. I works for me
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900