R
R
Roman Volkov2019-09-16 16:31:50
Vue.js
Roman Volkov, 2019-09-16 16:31:50

The value of input does not match v-model. How to solve the problem?

Here's a demo. https://jsfiddle.net/6t0jsz7h/2/
Let's say there is an input in which you can enter only phone numbers (a "+" sign and numbers).
I subscribe to the @input event, remove the forbidden characters, and put that value in the v-model variable.
The v-model value is correct, but the input itself displays illegal characters.
This will appear if you enter several invalid characters in a row. As soon as we enter an available one, input will take the correct value.
How to synchronize these values?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2019-09-16
@white_wolf_17

https://jsfiddle.net/y1ohwf2d/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question