Tabbar.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <TabBar
  3. :selectedTabIndex="current"
  4. @update:selectedTabIndex="changeTab"
  5. fixed
  6. xbarSpace
  7. :innerStyle="{
  8. zIndex: 999 ,
  9. boxShadow: '0 -2rpx 4rpx rgba(0, 0, 0, 0.1)',
  10. backdropFilter: 'blur(10px)',
  11. backgroundColor: 'rgba(246, 242, 231, 0.7)',
  12. }"
  13. >
  14. <TabBarItem icon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_home_off.png" activeIcon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_home_on.png" text="首页" />
  15. <TabBarItem icon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_discover_off.png" activeIcon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_discover_on.png" text="资讯" />
  16. <TabBarItem icon="https://mn.wenlvti.net/app_static/minnan/images/tabs/icon_inhert_off.png" activeIcon="https://mn.wenlvti.net/app_static/minnan/images/tabs/icon_inhert_on.png" hump :humpHeight="[0,0]" :humpSpace="[20,20]" :iconSize="140" text="传承" />
  17. <TabBarItem icon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_shop_off.png" activeIcon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_shop_on.png" text="乐游" />
  18. <TabBarItem icon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_profile_off.png" activeIcon="https://mncdn.wenlvti.net/app_static/minnan/images/tabs/icon_profile_on.png" text="我的" />
  19. </TabBar>
  20. </template>
  21. <script setup lang="ts">
  22. import TabBar from '@/components/nav/TabBar.vue';
  23. import TabBarItem from '@/components/nav/TabBarItem.vue';
  24. const props = defineProps({
  25. current: {
  26. type: Number,
  27. default: 0
  28. }
  29. });
  30. function changeTab(newVal: number) {
  31. switch(newVal) {
  32. case 0:
  33. switchTab('/pages/home/index', 0);
  34. break;
  35. case 1:
  36. switchTab('/pages/article/index', 1);
  37. break;
  38. case 2:
  39. switchTab('/pages/inhert/index', 2);
  40. break;
  41. case 3:
  42. switchTab('/pages/travel/index', 3);
  43. break;
  44. case 4:
  45. switchTab('/pages/user/index', 4);
  46. break;
  47. }
  48. }
  49. function switchTab(path: string, index: number) {
  50. if (props.current === index)
  51. return;
  52. uni.switchTab({
  53. url: path
  54. });
  55. }
  56. </script>