Dining_Hall/pages/components/Tabs.vue

75 lines
1.4 KiB
Vue
Raw Normal View History

2025-01-02 17:55:05 +08:00
<template>
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
2025-03-14 15:15:54 +08:00
<view class="list">
<view class="list-item" :class="{ active: active == index }"
v-for="(item, index) in tabList"
:key="index"
@click="handleTab(index)"
2025-01-02 17:55:05 +08:00
>
2025-03-14 15:15:54 +08:00
<view style="padding: 0 5px">{{ item }}</view>
<view v-if="active == index" class="line"></view>
</view>
</view>
2025-01-02 17:55:05 +08:00
</template>
<script>
2025-04-27 15:58:51 +08:00
2025-01-02 17:55:05 +08:00
export default {
props: {
tabList: {
type: Array,
default: () => []
}
},
data() {
return {
2025-04-27 15:58:51 +08:00
fontValue:uni.getStorageSync('fontSize') || 8,
active: 0
2025-01-02 17:55:05 +08:00
}
},
mounted() {
console.log('?? ~ mounted ~ tabs:', this.tabList)
2025-01-02 17:55:05 +08:00
},
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;
2025-02-19 09:34:34 +08:00
margin-bottom: 10px;
2025-01-02 17:55:05 +08:00
.list-item {
font-weight: 700;
font-size: 28rpx;
2025-01-02 17:55:05 +08:00
color: rgba(15, 39, 75, 0.8);
2025-03-14 15:15:54 +08:00
margin-right: 10px;
2025-01-02 17:55:05 +08:00
display: flex;
flex-direction: column;
align-items: flex-start;
position: relative;
}
.active {
font-weight: 500;
font-size: 32rpx;
2025-01-02 17:55:05 +08:00
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>