12345678910111213141516171819202122232425262728293031323334 |
- <template>
- <div class="w-full bg-white">
- <van-tabbar v-model="currentRouteName" safe-area-inset-bottom :fixed="false" @change="toPath">
- <van-tabbar-item :name="item.pathName" :icon="item.icon" v-for="item in tabBarOption">{{ item.title }}</van-tabbar-item>
- </van-tabbar>
- </div>
- </template>
- <script setup>
- import { ref, onActivated } from 'vue';
- import { useRoute } from 'vue-router'
- import { useLifecycle } from '@hooks/useCommon.js';
- import useRouterStore from "@store/useRouterStore.js";
- import tabBarOption from "../../tabBar"
- const route = useRoute()
- const router = useRouterStore()
- const currentRouteName = ref(route.name)
- function toPath(name) {
- router.switchTabBar({ pathName: name })
- }
- useLifecycle({
- load: () => {
- currentRouteName.value = route.name
- }
- });
- </script>
- <style lang='scss' scoped>
- /* 样式代码 */
- </style>
|