perf: 处理 alive

This commit is contained in:
奔跑的面条 2023-03-27 10:32:52 +08:00
parent 89d8134fad
commit 7620be2ca5
3 changed files with 16 additions and 27 deletions

View File

@ -1,13 +1,9 @@
<template> <template>
<router-view> <router-view>
<template #default="{ Component, route }"> <template #default="{ Component, route }">
<component <component v-if="route.meta.noKeepAlive" :is="Component"></component>
v-if="route.meta.noKeepAlive"
:is="Component"
:key="route.fullPath"
></component>
<keep-alive v-else> <keep-alive v-else>
<component :is="Component" :key="route.meta?.key"></component> <component :is="Component"></component>
</keep-alive> </keep-alive>
</template> </template>
</router-view> </router-view>

View File

@ -1,14 +1,14 @@
<template> <template>
<router-view #default="{ Component, route }"> <router-view #default="{ Component, route }">
<transition name="fade" mode="out-in" appear> <transition name="fade" mode="out-in" appear>
<component <component
v-if="route.noKeepAlive" v-if="route.meta.noKeepAlive"
:is="Component" :is="Component"
:key="route.fullPath" :key="route.fullPath"
></component> ></component>
<keep-alive v-else> <keep-alive v-else>
<component :is="Component" :key="route.fullPath"></component> <component :is="Component" :key="route.fullPath"></component>
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
</template> </template>

View File

@ -46,11 +46,4 @@ const projectRoutes: RouteRecordRaw = {
] ]
} }
projectRoutes.children?.forEach(child => {
child.meta = {
...child.meta,
key: 'reuse-project'
}
})
export default projectRoutes export default projectRoutes