<template>
<view class="container">
<view class="nav">
<view class="navItem" :class="navIndex == index ? ‘navActive‘:‘‘" v-for="(item,index) in navList" :key="index" @tap="navClick(index)">{{item}}</view>
</view>
<view class="navCont" v-if="navIndex == 0">全部内容</view>
<view class="navCont" v-if="navIndex == 1">卡一内容</view>
<view class="navCont" v-if="navIndex == 2">卡二内容</view>
<view class="navCont" v-if="navIndex == 3">卡三内容</view>
<view class="navCont" v-if="navIndex == 4">卡四内容</view>
<view class="navCont" v-if="navIndex == 5">卡五内容</view>
</view>
</template>
<script>
export default{
data() {
return {
navList: [‘全部‘,‘卡一‘,‘卡二‘,‘卡三‘,‘卡四‘,‘卡五‘],
navIndex: 0
}
},
methods: {
navClick(index) {
this.navIndex = index;
}
},
}
</script>
<style>
page{
background-color: #FAFAFA;
}
.nav{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100upx;
display: flex;
justify-content: space-around;
align-items: center;
background-color: #FFFFFF;
}
.navItem{
color: #333333;
font-size: 32upx;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
line-height: 100upx;
}
.navActive{
font-size: 42upx;
}
.navActive::after{
content: ‘‘;
width: 56upx;
height: 8upx;
background: #00ACFE;
margin-top: -8upx;
}
.navCont{
position: absolute;
top: 130upx;
}
</style>
原文:https://www.cnblogs.com/songmengwen1124/p/12899018.html