feat: 添加组件key (#251)

This commit is contained in:
悠静萝莉 2022-08-03 00:10:08 +08:00 committed by GitHub
parent 86eb38220d
commit 05d49fd2cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
<router-view v-if="!isRefreshing" v-slot="{ Component }">
<transition name="fade" mode="out-in">
<keep-alive :include="aliveViews">
<component :is="Component" />
<component :is="Component" :key="activeRouteFullPath" />
</keep-alive>
</transition>
</router-view>
@ -10,8 +10,14 @@
<script setup lang="ts">
import { computed, ComputedRef } from 'vue';
import { useRouter } from 'vue-router';
import { useTabsRouterStore } from '@/store';
const activeRouteFullPath = computed(() => {
const router = useRouter();
return router.currentRoute.value.fullPath;
});
const aliveViews = computed(() => {
const tabsRouterStore = useTabsRouterStore();
const { tabRouters } = tabsRouterStore;