-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathindex.vue
32 lines (26 loc) · 1.02 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script setup lang="ts">
import { useKeepAliveStore } from "@/pinia/stores/keep-alive"
import Footer from "./components/Footer.vue"
import NavBar from "./components/NavBar.vue"
import Tabbar from "./components/Tabbar.vue"
const route = useRoute()
const keepAliveStore = useKeepAliveStore()
const showNavBar = computed(() => route.meta.layout?.navBar?.showNavBar)
const showTabbar = computed(() => route.meta.layout?.tabbar?.showTabbar)
const showFooter = computed(() => route.meta.layout?.footer)
</script>
<template>
<div un-h-full un-flex un-flex-col>
<NavBar v-if="showNavBar" />
<div un-flex-1 un-overflow-y-auto>
<!-- key 采用 route.path 和 route.fullPath 有着不同的效果,大多数时候 path 更通用 -->
<router-view v-slot="{ Component }">
<keep-alive :include="keepAliveStore.cachedRoutes">
<component :is="Component" :key="route.path" />
</keep-alive>
</router-view>
<Footer v-if="showFooter" />
</div>
<Tabbar v-if="showTabbar" />
</div>
</template>