MtaTabBar.vue 633 B

123456789101112131415161718192021222324252627
  1. <template>
  2. <view class="custom-tabbar">
  3. <view v-for="(item, index) in tabList" :key="index" @click="switchTab(item)">
  4. <image :src="activeIndex === index ? item.selectedIcon : item.icon" />
  5. <text :style="{ color: activeIndex === index ? selectedColor : defaultColor }">
  6. {{ item.text }}
  7. </text>
  8. </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. const tabList = [{text: '首页',pagePath: '/pages/index/index'}, {text: '我的'}]
  13. const props = defineProps({
  14. activeIndex: {
  15. type: String
  16. }
  17. })
  18. function switchTab(item) {
  19. uni.switchTab({ url: item.pagePath });
  20. }
  21. </script>
  22. <style>
  23. </style>