[Vuejs]-Vue directive called but not updating value

3๐Ÿ‘

โœ…

If you want just change to uppercase easiest way is use style:

.uppercase{
    text-transform: uppercase;
}

Also use filter can another choice:

    filters: {
        uppercase: function(v) {
            return v.toUpperCase();
        }
    }

And if you want use directive as you use v-model got some problems so you can combine it with style solution:

Vue.directive("uppercase", {
    bind(el, binding, vnode) {
        el.style.textTransform = 'uppercase';
    },
    update(el, binding, vnode) {
        el.style.textTransform = 'uppercase';
    }
});

Here is simple codepen for directive for show all solutions

๐Ÿ‘คMohsen

Leave a comment