<template>
<view class="top">
<view @click="changeTabs(index)" v-for="(item, index) in topList" :key="index">{{ item.name }}</view>
<span class="active" :class="{ activeLeft:!tab, activeRight: tab }"></span>
</view>
</template>
<script>
export default{
data () {
return {
tab:false,
topList:[
{name:'吐槽墙'},
{name:'热榜'},
],
}
},
methods:{
// 点击切换标签
changeTabs(index){
if(index == 0){
this.tab = false
} else {
this.tab = true
}
console.log(this.tab)
},
}
}
</script>
<style lang="scss">
.active{
transition: all 0.2s ease;
}
.activeLeft{
position: absolute;
top: 8vh;
left: 35.5vw;
width: 10vw;
height: 0.5vh;
background-color: #fff;
margin: 0;
}
.activeRight{
position: absolute;
top: 8vh;
left: 57.5vw;
width: 10vw;
height: 0.5vh;
background-color: #fff;
margin: 0;
}
.top{
width: 100vw;
height: 10vh;
background-color: #2d2c28;
color: #fff;
display: flex;
line-height: 10vh;
font-size: 21px;
justify-content: center;
view{
margin-right: 5vw;
margin-left: 5vw;
}
}
</style>
11-16
1071
10-25
2571