列表点击高亮(个人笔记)

鼠标悬浮及点击选中后背景高亮

 :class="active == index ? 'height-style-1' : 'height-style-2'"

"动态绑定样式.

@click="isClick(index)" 通过索取下标

<div
  class="event"
  :class="active == index ? 'height-style-1' : 'height-style-2'"
  @click="isClick(index)"
  v-for="(item, index) in eventType"
  :key="index"
>
  <div class="event-type" @click="eventTypeClick(item.value)">
    {{ item.label }}
  </div>
</div>

js:代码

trun{

active: 0, //默认0

}

// 背景点击高亮
isClick(index) {
  this.active = index
}

style样式

 // 高亮样式

      .height-style-1 {

        .event-type {

          padding: 10px 0px 5px 10px;

          font-size: 14px;

          font-weight: 200;

          margin-bottom: 5px;

          background: linear-gradient(to right, #0e74d0, #5053fb);

//悬浮高亮

          &:hover {

            background: linear-gradient(to right, #0e74d0, #5053fb);

          }

        }

      }

      // 默认颜色

      .height-style-2 {

        .event-type {

          background: transparent;

        }

      }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值