当前位置:   article > 正文

【Vue】鼠标悬浮卡片展示可点击按钮

【Vue】鼠标悬浮卡片展示可点击按钮

 

  1. <div @mouseenter="handleMouseEnter(index)" @mouseleave="handleMouseLeave(index)"
  2. class="grid-item" v-for="(item, index) in segmentsList.data" :key="item.id">
  3. <el-card shadow="hover" class="w-full h-full card">
  4. <div class="flex justify-between items-center mb-2">
  5. <div class="w-10 text-center border bg-gray-50 border-gray-100 text-gray-500 px-2 rounded-md text-sm">
  6. #{{ index + 1 }}
  7. </div>
  8. </div>
  9. <div class="flex items-center">{{ item.content }}</div>
  10. <div class="create-text items-center flex justify-end text-gray-200" v-if="hoverItem[index]">
  11. <div class="el-icon-document mr-2 text-sm">{{ item.content.length }}字符</div>
  12. <el-button v-if="hoverItem[index]" @click.stop="handleDelete(item.id)" size="mini"><i class="el-icon-delete"></i></el-button>
  13. </div>
  14. </el-card>
  15. </div>
  1. handleMouseEnter(index) {
  2. this.$set(this.hoverItem, index, true);
  3. },
  4. handleMouseLeave(index) {
  5. this.$set(this.hoverItem, index, false);
  6. },
  1. data(){
  2. return {
  3. hoverItem:[]
  4. }
  5. }
  1. created() {
  2. if (this.segmentsList.data) {
  3. //将 this.hoverItem 数组初始化为与 this.segmentsList.data 数组长度相同,并将其所有元素都设置为 false
  4. this.hoverItem = new Array(this.segmentsList.data.length).fill(false);
  5. }
  6. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/383493
推荐阅读
相关标签
  

闽ICP备14008679号