【发布时间】:2020-04-22 09:03:04
【问题描述】:
我在头像悬停时创建了菜单,还从项目数组中添加了项目。现在点击项目,必须去特定的组件或项目。我试过这个:
模板:
<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>
【问题讨论】:
-
你有
vue-router吗?go specific component or item是什么意思?可以举个例子吗? -
“去特定的组件或项目”意味着你可以在图片中看到,如果我点击配置文件,它将转到 profile.vue 或点击注销,它将打开一个注销弹出窗口。我有 index.js,其中写入了路由。 @AliHosseini
-
所以在你的 item.title 上使用 switch-case
-
我不明白。你能告诉我@AliHosseini
标签: javascript menu vue-component vuetify.js menuitem-selection