标签:cli 动态 order font border tabbar control efault exp
<template>
<div class="tabcontrol">
<div class="tabcontrol-item" v-for="(item, index) in feature"
:key="index"
:class="{active: index === currentIndex}"
@click="itemClick(index)">
<span>{{item}}</span>
</div>
</div>
</template>
<script>
export default {
name: ‘TabControl‘,
props: {
feature: {
type: Array,
default: []
}
},
data(){
return {
currentIndex: 0 //记录当前点击的是哪一个就
}
},
methods: {
itemClick (index) {
//改变currentIndex
this.currentIndex = index
}
}
}
</script>
<style scoped>
.tabcontrol {
display: flex;
text-align: center;
background: #fff;
}
.tabcontrol-item {
flex: 1;
}
.active {
color: var(--color-high-text);
}
.active span {
border-bottom: 2px solid var(--color-high-text);
}
</style>
标签:cli 动态 order font border tabbar control efault exp
原文地址:https://www.cnblogs.com/lyt0207/p/12458481.html