index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <u-tabbar :value="tabbarValue" @change="tabbarChange" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" :border="true" :activeColor="proxy.$settingStore.themeColor.color">
  3. <u-tabbar-item :text="tab.text" v-for="(tab, index) in tabbarList" :key="index" :dot="tab.dot">
  4. <template #active-icon>
  5. <!-- <image style="width: 24px; height: 24px" :src="proxy.$settingStore.themeColor.tabList[index]"></image> -->
  6. <text class="iconfont font20" :class="tab.iconClass" :style="{ color: proxy.$settingStore.themeColor.color }"></text>
  7. </template>
  8. <template #inactive-icon>
  9. <!-- <image style="width: 24px; height: 24px" :src="tab.iconPath"></image> -->
  10. <text class="iconfont font20" :class="tab.iconClass" style="color: #7d7e80"></text>
  11. </template>
  12. </u-tabbar-item>
  13. </u-tabbar>
  14. </template>
  15. <script setup>
  16. /*----------------------------------依赖引入-----------------------------------*/
  17. import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  18. import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, watchEffect, toRefs } from "vue";
  19. /*----------------------------------接口引入-----------------------------------*/
  20. /*----------------------------------组件引入-----------------------------------*/
  21. /*----------------------------------store引入-----------------------------------*/
  22. /*----------------------------------公共方法引入-----------------------------------*/
  23. /*----------------------------------公共变量-----------------------------------*/
  24. const { proxy } = getCurrentInstance();
  25. /*----------------------------------变量声明-----------------------------------*/
  26. const props = defineProps({
  27. //数据集
  28. tabbarList: {
  29. type: Object,
  30. default: [],
  31. },
  32. //选中值
  33. tabbarValue: {
  34. type: Number,
  35. default: 0,
  36. },
  37. //是否使用tabBar跳转页面
  38. isSwitchTab: {
  39. type: Boolean,
  40. default: true,
  41. },
  42. });
  43. const { tabbarValue, tabbarList, isSwitchTab } = toRefs(props);
  44. function tabbarChange(e) {
  45. if (isSwitchTab.value) {
  46. console.log(tabbarList.value[e].pagePath)
  47. proxy.$tab.switchTab(tabbarList.value[e].pagePath);
  48. } else {
  49. proxy.$tab.redirectTo(tabbarList.value[e].pagePath);
  50. }
  51. }
  52. onLoad((option) => {});
  53. </script>