fix: 修复页面transition切换时出现X轴滚动条的问题

This commit is contained in:
zs 2023-03-22 15:02:53 +08:00
parent bb7448af2c
commit 28b6aed9a0
2 changed files with 10 additions and 8 deletions

View File

@ -1,11 +1,13 @@
<template>
<vanConfigProvider :theme="getDarkMode" :theme-vars="getThemeVars()">
<routerView v-slot="{ Component }">
<div class="absolute top-0 bottom-0 w-full overflow-hidden">
<transition :name="getTransitionName" mode="out-in" appear>
<keep-alive v-if="keepAliveComponents" :include="keepAliveComponents">
<component :is="Component" />
</keep-alive>
</transition>
</div>
</routerView>
</vanConfigProvider>
</template>

View File

@ -21,13 +21,13 @@ export const useRouteStore = defineStore({
},
},
actions: {
setRouters(routers) {
setRouters(routers: RouteRecordRaw[]) {
this.routers = routers;
},
setMenus(menus) {
setMenus(menus: RouteRecordRaw[]) {
this.menus = menus;
},
setKeepAliveComponents(compNames) {
setKeepAliveComponents(compNames: string[]) {
// 设置需要缓存的组件
this.keepAliveComponents = compNames;
},