123456789101112131415161718192021222324252627 |
- <template>
- <view class="custom-tabbar">
- <view v-for="(item, index) in tabList" :key="index" @click="switchTab(item)">
- <image :src="activeIndex === index ? item.selectedIcon : item.icon" />
- <text :style="{ color: activeIndex === index ? selectedColor : defaultColor }">
- {{ item.text }}
- </text>
- </view>
- </view>
- </template>
- <script setup>
- const tabList = [{text: '首页',pagePath: '/pages/index/index'}, {text: '我的'}]
- const props = defineProps({
- activeIndex: {
- type: String
- }
- })
-
- function switchTab(item) {
- uni.switchTab({ url: item.pagePath });
- }
- </script>
- <style>
- </style>
|