Answer the question
In order to leave comments, you need to log in
How to bind input via v-model in a loop?
Good afternoon!
<template v-for="(item, index) in items">
<input type="checkbox" v-model="item.checked" />
</template>
computed: {
items: {
get () {
return this.$store.state['options'].items;
},
set (value) {
this.$store.commit('options/SET_ITEMS_PROPERTY', value);
}
}
}
Answer the question
In order to leave comments, you need to log in
The v-model should be an array, not the state of a particular checkbox; in addition, checkboxes should specify values. There is an example in the documentation . Accordingly, your code can (but not the fact that you need to) rewrite something like this , for example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question