Vue js apply filter on v-model in an input field

前端 未结 7 1699
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-03 22:37

Hope someone can help me! I have made a directive wrapping the Jasny Bootstrap Plugin more specifically the input-mask thing and everything goes well!

Now I have made a

7条回答
  •  暖寄归人
    2021-02-03 23:04

    Go to main.js and add the following code :

    import moment from 'moment'
    Vue.filter('myDate', function (value) {
        if (value) {
            return moment(String(value)).format('dd/mm/yyyy')
        }
    });
    

    In your HTML do the following :

    
    
    

    {{ date | myDate 'dd/mm/yyyy' }}

    So we used above v-bind to bind the value and @input event handler to have the v-model functionality.

提交回复
热议问题