效果图:

wxml代码:
{{item}}
wxss代码:
.top_tabbar{
width: 100%;
background-color: #ffffff;
display: flex;
position: fixed;
}
.item_name{
text-align: center;
margin:20rpx 60rpx;
color: grey;
}
.active{
color: lightgreen;
}
.active text{
padding-bottom: 10rpx;
border-bottom: 4rpx solid lightgreen;
}js代码:
data:{
itemName: ["军事", "明星", "动漫","风景"],
tabIndex: 0
},
//获取点击事件
handleItem(e){
// console.log(e)
const index = e.currentTarget.dataset.index
this.setData({
tabIndex: index
})
}