footer.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div class="w-full bg-white">
  3. <van-tabbar v-model="currentRouteName" safe-area-inset-bottom :fixed="false" @change="toPath">
  4. <template v-for="item in tabBarOption">
  5. <van-tabbar-item :name="item.pathName" :icon="item.icon" v-if="item.pathName != 'news'">{{ item.title
  6. }}</van-tabbar-item>
  7. <van-tabbar-item :name="item.pathName" :icon="item.icon"
  8. :badge="userInfo.numberOfMessages" v-else>{{ item.title }}</van-tabbar-item>
  9. </template>
  10. </van-tabbar>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ref, onActivated } from 'vue';
  15. import { useRoute } from 'vue-router'
  16. import { useLifecycle } from '@hooks/useCommon.js';
  17. import useRouterStore from "@store/useRouterStore.js";
  18. import useInfoStore from "@store/useInfoStore.js";
  19. import tabBarOption from "../../tabBar"
  20. const route = useRoute()
  21. const router = useRouterStore()
  22. const currentRouteName = ref(route.name)
  23. const userInfo = useInfoStore()
  24. function toPath(name) {
  25. router.switchTabBar({ pathName: name })
  26. }
  27. useLifecycle({
  28. load: () => {
  29. currentRouteName.value = route.name
  30. }
  31. });
  32. </script>
  33. <style lang='scss' scoped>
  34. /* 样式代码 */
  35. </style>