V
V
Vitalionus2020-05-02 18:46:34
Vue.js
Vitalionus, 2020-05-02 18:46:34

How to change v-model in vuetify?

Good afternoon, here's the deal.
v-text-field
It is used in the template. I use v-model="form.myValue"
watch for processing.
I need only numbers and a space in myValue.
But in vuetify there is such a thing that it takes the value not from the v-model,
but from the lazyValue which is in the data of the v-text-field That is, in fact form.myValue

= '34 ' somewhere inside it, the full input value is stored in lazyValue

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2020-05-02
@tyllo

In your watcher, just wrap your character filter in $nextTick, i.e. something like

{
  watch: {
    'form.myValue'(value) {
      this.$nextTick(() => this.form.myValue = value.replace(/[^0-9 ]/g, ''))
    },
  },
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question