I have a custom tree-view component that I'm working on:
<template>
<li class="main__li list" :style="{'margin-left': `${depth * 20}px` ,'background-color': `${col}`}" @click="toggle(e); getEl($event)" :title="tree.name">{{tree.name}} </li>
<ul v-show="isOpen" v-if="isFolder" class="ul__ctg list">
<TreeView :tree="chld" v-for="(chld, inx) in tree.children" :key="inx" :depth="depth +1"></TreeView>
</ul>
</template>
Here is the script where I'm trying to change the color of an item when clicked:
getEl(e){
this.col = 'blue'
//how turn previous item`s color back?
return this.tree.id
},
I am struggling with reverting the color of the previously selected item back to its initial state. When I click on an item, it changes color as intended, but making sure the previous selection goes back to normal has been a challenge for me.