Dining_Hall/pages/components/Tabs.vue

74 lines
1.3 KiB
Vue

<template>
<div class="list">
<div
class="list-item"
:class="{ active: active == index }"
v-for="(item, index) in tabList"
:key="index"
@click="handleTab(index)"
>
<div style="padding: 0 5px">{{ item }}</div>
<div v-if="active == index" class="line"></div>
</div>
</div>
</template>
<script>
export default {
props: {
tabList: {
type: Array,
default: () => []
}
},
data() {
return {
active: 0
}
},
mounted() {
console.log('🚀 ~ mounted ~ tabs:', this.tabList)
},
methods: {
handleTab(index) {
this.active = index
this.$emit('changeTab', index)
}
}
}
</script>
<style lang="scss" scoped>
.list {
display: flex;
justify-content: flex-start;
align-items: center;
margin-bottom: 10px;
.list-item {
font-weight: 700;
font-size: 12px;
color: rgba(15, 39, 75, 0.8);
margin-right: 30px;
display: flex;
flex-direction: column;
align-items: flex-start;
position: relative;
}
.active {
font-weight: 500;
font-size: 14px;
color: #0f274b;
z-index: 9;
}
.line {
width: 36px;
height: 8px;
background: linear-gradient(90deg, #ff6816 0%, rgba(255, 104, 22, 0) 100%);
border-radius: 4px 4px 4px 4px;
position: absolute;
bottom: 0px;
}
}
</style>