<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 循环为选中的li列表添加效果</title>
</head>
<style>
li{
list-style: none;
}
.active {
background: rgba(135, 135, 135, 0.74);
width: 20%;
color: #eee;
}
</style>
<body>
<script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>

<div > },
       mounted(){
$("ul li:first-child").addClass('active');//第一个默认选中
},

methods: {
addClassFun: function (index) {
this.classID = index;
           $("ul li:first-child").removeClass('active'); 切换的时候第一个不要选中

}
}
})
</script>
</body>
</html>

相关文章:

  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案