Vue component Mask is only applied when stirring the field

Asked

Viewed 596 times

1

I’m learning to use vue and vuetify and I’m using a library to make fields with masks.

The bike in question is Vue-Mask.

When loading the component, the mask is not applied automatically unless I move the field, or type something again.

<v-text-field
    v-model="item.phone"
    v-mask="'(##) #####-####'"
    label="Telefone"
/>

Export the component globally.

import VueTheMask from 'vue-the-mask';
Vue.use(VueTheMask)

Someone knows how to fix this?

3 answers

2

as a directive, Vuethemask Mask is called by mask="".. Also, there’s no reason to use quotes and then single quotes inside.. put this way in the component: mask="(##) #####-####"

0

This will work as you expect

<v-text-field
   v-model="item.phone"
   :value="item.phone.toString()"
   v-mask="'(##) #####-####'"
   label="Telefone"
/>

-3

had the same problem trying to set field value in Mounted. I switched to created and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.