I have code below for category selection. When a category is selected, it sets its background to green, otherwise the background is gray; this works fine.
What I want to achieve is when I select multiple items, I want it to keep the background green for all selected categories. Is there a way to do this?
<div class="categories" v-for="(category, index) in categories" :key="index" @click="Add( category._id, index)" :class="[isediting && selectedIndex == index ? 'green' : 'gray']">
{{ category.category_name }}
</div>
<script>
methods: {
Add(AddCategory, index) {
this.AddCategory.push(AddCategory);
this.selectedIndex = index;
this.isediting = true;
},
</script>
<style>
.green {
background-color: #41B883;
}
.gray {
background-color: #e5e0ed;
}
</style>