【发布时间】:2019-01-16 20:32:26
【问题描述】:
我有 3 张卡片,当鼠标悬停在卡片标题上时,它会显示一个 arrow_down 图标,我可以单击它,当我将鼠标悬停在 v-card-title 上时,它会显示一个带有删除功能的下拉菜单,但在我之后单击它,鼠标在下拉菜单上的箭头图标消失了, 如何正确实施?
https://codepen.io/sharon-the-encoder/pen/WLWyoG?editors=0010
const cards = [
{
title: "Gooey PBJ Brownies",
author: "John Walibur",
image: "https://placeimg.com/640/480/nature"
},
{
title: "Crisp Spanish Tortilla Matzo Brei",
author: "Colman Andrews",
image: "https://placeimg.com/640/480/animals"
},
{
title: "Grilled Shrimp with Lemon and Garlic",
author: "Celeste Mills",
image: "https://placeimg.com/640/480/arch"
}
];
new Vue({
el: "#app",
data: {
cards: cards,
selectedCard: -1
},
methods: {
hoverCard(selectedIndex) {
this.selectedCard = selectedIndex
},
isSelected(cardIndex) {
return this.selectedCard === cardIndex
},
passmsgid(index) {
alert(index)
}
}
});
body {
background-color: #e1e7e7;
}
.grey--text.selected {
color: red !important;
}
.iconkey {
display: none;
}
.iconkey.selected {
display: block;
color: blue !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.18/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuetify/1.4.2/vuetify.min.js">
</script>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons'>
<div id="app">
<v-app>
<v-content>
<v-container>Hello world</v-container>
<v-container fluid>
<v-layout row wrap>
<v-flex xs12 sm4 md4 lg4 v-for="(card, index) in cards" :key="index">
<v-card class="ml-3 mt-3">
<v-img :src="card.image" height="200px">
</v-img>
<v-card-title primary-title @mouseover="hoverCard(index)" @mouseout="hoverCard(-1)">
<div>
<div class="headline">{{card.title}}</div>
<span class="grey--text" :class="{'selected': isSelected(index)}">{{card.author}} -
</span>
<v-expand-transition>
<v-menu bottom transition="scale-transition" nudge-bottom="40">
<v-btn icon slot="activator" styole="margin-bottom: -1em;">
<v-icon class="iconkey" :class="{'selected': isSelected(index)}">keyboard_arrow_down</v-icon>
</v-btn>
<v-list>
<v-list-tile>
<v-list-tile-title @click="passmsgid(index)">Delete</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-expand-transition>
</div>
</v-card-title>
<v-card-actions>
<v-btn flat>Share</v-btn>
<v-btn flat color="purple">Explore</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
</div>
【问题讨论】:
-
你必须有@click
,所以 <v-list-tile @click="">(你把它放在上) -
@Traxo 请查看我的 codepn 示例,我无法在 stackoveflow 上重现它
-
@Traxo 没关系,但是当我将鼠标悬停在卡片标题上时问题仍然存在,它会显示 arrow_down 图标,我可以单击它,然后当我将鼠标悬停在下拉菜单(删除)图标被隐藏我希望即使我的鼠标在下拉菜单上也能留在那里
-
对不起,我误会了。以为你的意思是正确的光标不见了,哈哈。我建议你看看
<v-hover>组件是否适合你,然后使用它,这样你就不用使用悬停功能——我认为这些不是必需的。我认为我过去解决了这个问题,但必须搜索我是如何解决的,然后我可以使用 v-hover 为您提供答案。但是直到明天才有时间,所以希望其他人能来帮忙。
标签: mouseover vuetify.js