| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <template>
- <view class="bottom-nav">
- <!-- 底座(可加背景色或阴影) -->
- <view class="tabbar-platform"></view>
- <view v-for="(item, index) in tabs" :key="index" class="nav-item" :class="{ active: currentIndex === index }"
- @click="handleClick(index)">
- <text class="nav-text">{{ item.text }}</text>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- // Props & Emits
- interface TabItem {
- text : string;
- }
- interface Props {
- currentIndex : number;
- }
- const props = defineProps<Props>();
- const emit = defineEmits<{
- (e : 'change', index : number) : void;
- }>();
- // 配置数据(可从 props 接收)
- const tabs : TabItem[] = [
- { text: '小丁' },
- { text: '理疗' },
- { text: '预约' },
- { text: '商户' },
- { text: '我的' }
- ];
- // 方法
- const handleClick = (index : number) => {
- emit('change', index);
- };
- </script>
- <style scoped>
- .tabbar-platform{
- background-color: #ffffff;
- box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
- height: 100rpx;
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- }
- /* 底部导航容器 */
- .bottom-nav {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- align-items: flex-end;
- padding: 10rpx 0 ;
-
- z-index: 1;
- }
- /* 单个导航项 */
- .nav-item {
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: #ffa500;
- /* 橙色背景 */
- color: #ffffff;
- /* 白色文字 */
- font-size: 26rpx;
- font-weight: bold;
- transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
- position: relative;
- }
- /* 选中状态 */
- .nav-item.active {
- width: 110rpx;
- height: 110rpx;
- transform: translateY(-10rpx);
- /* 上浮 */
- z-index: 10;
- background-color: #ffffff;
- /* 白底 */
- color: #ffa500;
- /* 橙色文字 */
- box-shadow: 0 8rpx 20rpx rgba(255, 165, 0, 0.4);
- }
- /* 文字样式 */
- .nav-text {
- line-height: 1;
- }
- </style>
|