I have created menu on avatar hover and also added item from item array. Now clicking on the items, have to go specific component or item. I tried this:
template:
<template>
<div>
<v-menu offset-y open-on-hover>
<template v-slot:activator="{ on }">
<v-avatar color="white" size="38" v-on="on">
<span class="primary--text headline">A</span>
</v-avatar>
</template>
<v-list>
<v-list-item
v-for="(item, index) in items"
:key="index"
@click="selectSection(item)" >
<v-list-item-title>{{ item.title }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</div>
</template>
Script:
<script>
export default {
data: () => ({
items: [
{ title: '[email protected]' },
{ title: 'Profile' },
{ title: 'Logout' },
],
}),
methods: {
selectSection(item) {
this.selectedSection = item;
}
}
</script>
use switch-case in your items like this:
and instead of
console.log()
s use your code for example to go to profile page instead ofconsole.log('Profile')
put$router.push('/profile')
hope it helps you