question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v-mask not working correctly with veutify input

See original GitHub issue

I’m using veutifyjs text-input to show phone number. I have a button to assign phone number to v-model. But after assign it not change there text input. if I enter some think on text-input v-mask work. But if I assign value to v-model it not working. Also i’m tying next trick but its not have any difference.

 <v-text-field
          v-model="form.phone_number"
          v-mask="'(###) ###-####'"
          dense
          outlined
          autocomplete="new-password"
          hide-details="auto"
          label="Phone Number"
          placeholder="Phone Number"
        ></v-text-field>

   <v-btn color="warning" @click="dataupdate()">Add</v-btn>
dataupdate() {
      this.$nextTick(() => {
        this.form.phone_number = '4032223344'
      })
    },

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:7

github_iconTop GitHub Comments

5reactions
davidkhesscommented, Jun 2, 2021

A workaround for this is to put a v-if on the Vuetify text field and toggle it after setting the model value like this:

 <v-text-field
          v-if="text_field_enabled"
          v-model="form.phone_number"
          v-mask="'(###) ###-####'"
          dense
          outlined
          autocomplete="new-password"
          hide-details="auto"
          label="Phone Number"
          placeholder="Phone Number"
        ></v-text-field>
                this.form.phone_number = value;
                this.text_field_enabled = false;
                this.$nextTick(() => { this.text_field_enabled = true; });

It’s a hack but the directive is not hooking to the model and listening for value changes correctly.

3reactions
alxxndercommented, Jan 17, 2022

Everything is much simpler, I ran into it myself and decided.

The fact is that vuejs cannot understand when the state changes, or rather when to render the component again, and needs a little help for it.

It is enough to remember about the key. After assigning a new value, you need to change the key. Vue will notice that the key will change in the virtual tree and re-render part of the code.

Screenshot_4

Using of v-bind:key solved the issue, great hint!

Read more comments on GitHub >

github_iconTop Results From Across the Web

v-mask not working correctly with veutifyjs input - Stack Overflow
I have a button to assign phone number to v-model. But after assign it not change there text input. if I enter some...
Read more >
v-mask not working correctly with veutifyjs input-vuetify.js
[Solved]-v-mask not working correctly with veutifyjs input-vuetify. js. Set it as the v-mask value: <v-text-field v-model="form.
Read more >
Vuetify mask - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
Upgrade Guide — Vuetify
Do not install node-sass, it is not the correct library. ... The selected prop is now input-value or v-model; The close event is...
Read more >
How to transform input values using v-mask when building ...
In this article, we are going to be looking at input masking. ... You can clearly see that the first example is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found