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>
<router-view>
<template #default="{ Component, route }">
<component
v-if="route.meta.noKeepAlive"
:is="Component"
:key="route.fullPath"
></component>
<component v-if="route.meta.noKeepAlive" :is="Component"></component>
<keep-alive v-else>
<component :is="Component" :key="route.meta?.key"></component>
<component :is="Component"></component>
</keep-alive>
</template>
</router-view>

View File

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

View File

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