优化菜单切换导致浏览器刷新问题

This commit is contained in:
guanj
2026-07-09 15:40:56 +08:00
parent 8bca4191f2
commit ee9cd057b8
6 changed files with 233 additions and 193 deletions

View File

@@ -1,9 +1,9 @@
<template>
<el-main class="layout-main" :style="mainHeight()">
<router-view v-slot="{ Component }">
<transition :name="config.layout.mainAnimation" mode="out-in">
<transition :name="config.layout.mainAnimation">
<keep-alive :include="state.keepAliveComponentNameList">
<component :is="Component" :key="state.componentKey" />
<component :is="Component" :key="state.componentKey || undefined" />
</keep-alive>
</transition>
</router-view>
@@ -32,7 +32,7 @@ const state: {
componentKey: string
keepAliveComponentNameList: string[]
} = reactive({
componentKey: route.path,
componentKey: '',
keepAliveComponentNameList: []
})
@@ -79,7 +79,6 @@ onMounted(() => {
watch(
() => route.path,
() => {
state.componentKey = route.path
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
}