S
S
SvizzZzy2018-06-11 11:51:28
Vue.js
SvizzZzy, 2018-06-11 11:51:28

How to change input value when using v-model on multiple input vue js?

Part of vue js code:

<input type="text" v-model="counts[item.id]" @change="changeCount(item.id, $event.target.value)">
 
Метод изменения vm.counts для нужного id: 
changeCount(id, c){

    let vm = this;
    vm.counts[id] = c; 
    console.log(vm.counts);
},

counts is denoted as a counts object: {};
When you manually change the input value, new data is added to counts[item.id] but visually the input value data does not change, it instantly discards the passed value. I can't figure out what's wrong. (you type data into the input - you remove the mouse cursor focus on another html element - the input value is reset to the previous value)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-06-11
@SvizzZzy

Remove the change event handler, it's not needed here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question