我在头像悬停时创建了菜单,还从项目数组中添加了项目。现在点击项目,必须去特定的组件或项目。我试过这个:
模板:
<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>
export default {
data: () => ({
items: [
{ title: 'abcd.xyz@example.com' },
{ title: 'Profile' },
{ title: 'Logout' },
],
}),
methods: {
selectSection(item) {
this.selectedSection = item;
}
}
</script>