<template> <view class="content"> <view class="items" v-for="(item,index) in tabList" :key="item.name" @click="tabsClick(index)"> <view class="flex-col"> <span :class="currentIndex == index ? 'active' : 'default'">{{item.name}}</span> <span class="line-through" v-show="currentIndex == index"></span> </view> </view> </view> </template> <script> export default { name: "tabs", props:[], data() { return { currentIndex:0, tabList: [{ name: '聊天室', id:"chat" }, { name: '课件', id:"courseware" }, { name: '直播详情', id:"sinatv" }] }; }, methods:{ tabsClick(index){ this.currentIndex = index this.$emit("skipComponent",this.tabList[index].id) } } } </script> <style lang="scss" scoped> .content { display: flex; height: 80rpx; font-size: 32rpx; box-shadow: 0 2rpx 10rpx #dadada;; .items { flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; .line-through{ width: 40rpx; height: 6rpx; background-color: #1374E7; margin-top: 6rpx; } } } .flex-col{ display: flex; flex-direction: column; align-items: center; justify-content: center; } .active{ color:#1374E7 } .default{ color:#999999 } </style>