page-tabbar.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <uv-tabbar :value="tabBarValue" activeColor="#2E64FA" inactiveColor="#C7CBD6" @change="changeTabBarValue">
  3. <uv-tabbar-item v-for="item in tabBarList" :key="item.pathName" :name="item.pathName" :text="item.text">
  4. <template v-slot:active-icon>
  5. <image class="icon" :src="item.selectedIconPath" style="width:48rpx;height:48rpx"></image>
  6. </template>
  7. <template v-slot:inactive-icon>
  8. <image class="icon" :src="item.iconPath" style="width:48rpx;height:48rpx"></image>
  9. </template>
  10. </uv-tabbar-item>
  11. </uv-tabbar>
  12. </template>
  13. <script setup>
  14. import uvTabbar from '@/uni_modules/uv-tabbar/components/uv-tabbar/uv-tabbar.vue';
  15. import uvTabbarItem from '@/uni_modules/uv-tabbar/components/uv-tabbar-item/uv-tabbar-item.vue';
  16. import { reactive } from 'vue';
  17. const emit = defineEmits(['ChangeTabBarValue']);
  18. const props = defineProps({
  19. tabBarValue: {//默认选中的tab
  20. type: String,
  21. default: () => ''
  22. },
  23. tabBarList: {
  24. type: Array,
  25. default: () => []
  26. }
  27. });
  28. const state = reactive({
  29. })
  30. //切换tabBar
  31. const changeTabBarValue = (name) => {
  32. emit('ChangeTabBarValue',name)
  33. }
  34. </script>