Vue点击改变属性(改变文字颜色)
2024-08-28 08:28:28
<template>
<div class="tab-control">
<div v-for="(item , index) in title" class="tab-control-item"
:class="{active: index === currentIndex}" @click='itemClick(index)'>
<span>{{item}}</span>
</div>
</div>
</template> <script>
export default {
name: 'TabControl',
data:{
title:["新款" , "流行" , "推荐"]
}
}
},
data(){
return{
currentIndex: 0
}
},
methods: {
itemClick(index){
this.currentIndex = index;
this.$emit('tabClick', index)
}
},
}
</script> <style scoped>
.tab-control{
display: flex;
text-align: center;
font-size: 15px;
height: 40px;
line-height: 40px;
background-color: #fff;
} .tab-control-item{
flex:1;
} .tab-control-item span{
padding: 5px;
} .active{
color: deeppink
} .active span{
border-bottom: 3px solid deeppink;
} .tab-control{
position: sticky;
top: 44px
}
</style>
最新文章
- 如何使用yum 下载 一个 package ?如何使用 yum install package 但是保留 rpm 格式的 package ? 或者又 如何通过yum 中已经安装的package 导出它,即yum导出rpm?
- oracle用户创建及权限设置
- Android——GridLayout
- codevs 1078 最小生成树
- Word Pattern
- 数据结构(线段树):BZOJ 1018: [SHOI2008]堵塞的交通traffic
- Ajax请求安全性讨论 - Eric.Chen(转)
- WPF中控件ListView和DataGrid典型属性介绍
- java foreach实现原理
- 流水线技术原理和Verilog HDL实现(转)
- DDD理论学习系列(10)-- 聚合
- Akka(17): Stream:数据流基础组件-Source,Flow,Sink简介
- 计算理论:NFA转DFA的两种方法
- Django Cookie和Seesion
- git branch 不显示的原因
- MFC中运行出现问题“不支持尝试执行的操作”
- iOS 转换异步block为同步方式运行
- App.config和Web.config配置文件的配置节点的解析
- Jquery、Ajax实现新闻列表页分页功能
- Pairwise