R
R
rockerok_n2018-05-16 16:48:23
Vue.js
rockerok_n, 2018-05-16 16:48:23

How to style checkboxes created in a v-for loop without breaking them?

When styling checkboxes created by the v-for directive, there was a problem: only the first checkbox is activated, no matter which element of the array is clicked on. The original checkboxes work fine. Key added both to the label and to the input, but only the first checkbox still works. What could be the problem?
Example https://jsfiddle.net/rokerok_22/8bowaa8s/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2018-05-16
@rokerok_n

Should it be like this ?
First, the v-for must be on the li element, not the ul element. Secondly, in order to dynamically assign attribute values ​​(you have id and for), you still need to use v-bind, and not just enter a string that matches the index name from v-for.

S
Sergey Leshchenko, 2018-05-16
@zellenka

Your id is repeated, just wrap the input with a label, without using for.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question