Merge pull request #7 from fairy-iu/main

fix: 修复页面transition切换时出现X轴滚动条的问题
This commit is contained in:
傲慢或香橙 2023-03-25 17:21:53 +08:00 committed by GitHub
commit 51d91886cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
},