[Vuejs]-Change the background color of a list item in Vuetify

1👍

You could use an array of activeItems and a toggle method like…

toggleActive(idx) {
   let pos = this.activeItems.indexOf(idx)
   pos === -1 ? this.activeItems.push(idx) : this.activeItems.splice(pos,1)
}

Then check if the item is in the array of activeItems…

    <v-list two-line subheader>
           <v-list-item v-for="(item,idx) in items" 
                @click="toggleActive(idx)" 
                :class="{active: activeItems.indexOf(idx)>-1}" 
                :key="item.title">...
           </v-list-item>
    </v-list>

Demo

Leave a comment