Why v-model attribute behaves differently

648 views Asked by At

Two equal examples (according to Vue.js) work differently:

First

<input v-model="value" @input.once="setDirty" type="text" id="object-email">

Second:

<input v-bind:value="value" v-on:input="value = $event.target.value"
                   @input.once="setDirty"
                   type="text"
                   id="object-email">

In the first example value changes only after second input, while the second example works correctly. If we delete @input.once attribute, two examples will work fine.

P.S. Vue 2.4.0

1

There are 1 answers

0
thanksd On

This was a bug that was fixed in version 2.4.3.

As a workaround for previous versions, you can simply use @keydown.once="setDirty" instead of @input.once.