Answer the question
In order to leave comments, you need to log in
How to make a class added and removed with v-for only on click on this element?
How to make a class added and removed with v-for only on click on this element? I tried here , but it turned out that if I click on another element, then the open one closes, and I need it to close only if I click on it
Answer the question
In order to leave comments, you need to log in
Add to each element of the array a property responsible for the presence of a class:
todos: [
{ open: false, ... },
{ open: false, ... },
...
],
@click="todo.open = !todo.open"
:class="{ 'dropdown-active': todo.open }"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question