I have a list item here on which i am looping to get a list of icons. Now i am trying to create a computed property such that if i am my $route.params.page === 'something' the first icon will get highlighted, if i am my $route.params.page === 'something else', the second icon gets highlighted and so on. But i am not sure how to go about it.
new Vue({
el: '#app',
data() {
return {
iconActions: [{
icon: 'android'
},
{
icon: 'dashboard'
},
{
icon: 'book'
},
{
icon: 'public'
},
{
icon: 'timeline'
}
],
}
},
computed: {
highlightIcon() {
if (this.$route.params.page === 'something') {
highlight 'first Icon'
} else if (this.$route.params.page === 'something') {
highlight 'second icon'
}
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet" />
<div id="app">
<v-app>
<v-list v-for="(icon,i) in iconActions" :key="`${i} - ${icon}`" :class="highlightIcon ? 'white--text bg-secondary' : ''">
<v-list-tile>
<v-icon>{{icon.icon}}</v-icon>
</v-list-tile>
</v-list>
</v-app>
</div>
Here is a link to the pen