Search code examples
vue.jscalendarv-model

What's the difference between v-model.trim and v-model?


enter image description here It's occurring error when I am using v-model.trim with Calendar

<Calendar id="birth_date" v-model.trim="employeeSetup.birth_date" :showButtonBar="true" required="true" :class="{'p-invalid': submitted && !employeeSetup.birth_date}" ref="birth_date" v-on:keyup.enter="this.$refs.gender.$el.focus()" />

But it's working perfectly when I am using v-model.trim with InputText


Solution

  • trim is a modifier that removes any extra space in your input text :

    <input type="text" v-model.trim="name" />
    

    it uses the js function trim() of strings :

    let s="brahim "
    console.log(s+'boussadjra')
    let t=s.trim() //removes the space
    
    console.log(t+'boussadjra')

    the calendar is a custom component which is not a simple input