Skip to content
Advertisement

How to toggle colors in list in Vue?

I have a tree-view component:

JavaScript

my not working script:

JavaScript

I just want to toggle the item’s color, which I choosed, that is when I click an item(im my code this item has @click event) I want to this item change its color to another, but its huge problem to me to turn back previous item to initial color. Ive struggled many hours on it

Advertisement

Answer

As per your requirement, You have to add default color initially to your every tree object and then on click you can perform toggle.

Live Demo :

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement