Answer the question
In order to leave comments, you need to log in
How to bind such data in vue?
There is a component:
I use vuex, only an array of Title strings is sent from the server to the store.
How can I tie all this so that it flies to the server, as well as an array of title strings that have been selected, and when it arrives from the server, somehow tie it to the component.
Answer the question
In order to leave comments, you need to log in
You make one more calculated property - an array of selected elements. The getter gets the corresponding array from the store, the setter causes a mutation. Use this property in v-model
checkboxes. You rewrite the computed property that controls the selection of all checkboxes as follows: in the getter you compare the lengths of the arrays of all elements and the selected ones, in the setter you set the value of the computed property of the selected elements. For example.
If I correctly caught the essence of the issue, then the solution, as always, is in the documentation ) here is an example
<input type="checkbox" id="jack" value="Джек" v-model="checkedNames">
<label for="jack">Джек</label>
<input type="checkbox" id="john" value="Джон" v-model="checkedNames">
<label for="john">Джон</label>
<input type="checkbox" id="mike" value="Майк" v-model="checkedNames">
<label for="mike">Майк</label>
<br>
<span>Отмеченные имена: {{ checkedNames }}</span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question