fix KeepAlive不生效问题

This commit is contained in:
不做码农 2022-05-24 11:08:23 +08:00
parent d5ebedfded
commit 90a163cb58
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
<template>
<el-main class="app-main">
<router-view v-slot="{ Component, route }" :key="route.path">
<router-view v-slot="{ Component, route }">
<transition appear name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews">
<component :is="Component" :key="route.path" />

View File

@ -12,7 +12,7 @@
<tags-view v-if="needTagsView" />
</el-header>
<el-main class="app-main">
<router-view v-slot="{ Component, route }" :key="route.path">
<router-view v-slot="{ Component, route }">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews">
<component :is="Component" :key="route.path" />
@ -39,7 +39,7 @@ const menuDrawer = computed({
store.dispatch('app/toggleSideBar')
},
})
const store = useStore()
let store = useStore()
const theme = computed(() => store.state.settings.theme)
const sidebar = computed(() => store.state.app.sidebar)
const device = computed(() => store.state.app.device)
@ -47,11 +47,13 @@ const needTagsView = computed(() => store.state.settings.tagsView)
const fixedHeader = computed(() => store.state.settings.fixedHeader)
const showFooter = computed(() => store.state.settings.showFooter)
// appMain start
const route = useRoute()
store.dispatch('tagsView/addCachedView', route)
const cachedViews = computed(() => {
return store.state.tagsView.cachedViews
})
//appMain
const classObj = computed(() => ({
hideSidebar: !sidebar.value.opened,