diff --git a/src/layout/components/Tabs/index.vue b/src/layout/components/Tabs/index.vue index f23f5ae..ba06949 100644 --- a/src/layout/components/Tabs/index.vue +++ b/src/layout/components/Tabs/index.vue @@ -56,8 +56,8 @@ tabsStore.reset() // 路由发生改变触发 const handleRouteChange = () => { const item = { ...route } as unknown as RouteRecordRaw - tabsStore.addTagItem(item) - tabsStore.addCacheItem(item) + tabsStore.addTagItem(toRaw(item)) + tabsStore.addCacheItem(toRaw(item)) // console.log('路由对象', toRaw(item)) // console.log('tagList', toRaw(tabsStore.tagList)) // console.log('cacheList', toRaw(tabsStore.cacheList)) diff --git a/src/stores/modules/tabs.ts b/src/stores/modules/tabs.ts index a63a458..e4f36e0 100644 --- a/src/stores/modules/tabs.ts +++ b/src/stores/modules/tabs.ts @@ -10,8 +10,7 @@ const storeSetup = () => { const cacheList = ref([]) // keep-alive缓存的数组, 元素是组件名 // 添加一个页签, 如果当前路由已经打开, 则不再重复添加 - const addTagItem = (route: RouteRecordRaw) => { - const item = JSON.parse(JSON.stringify(route)) + const addTagItem = (item: RouteRecordRaw) => { if (tagList.value.some((i) => i.path === item.path)) return if (item.meta?.showInTabs ?? true) { tagList.value.push(item) @@ -36,7 +35,7 @@ const storeSetup = () => { const arr: RouteRecordRaw[] = [] _XEUtils_.eachTree(routeStore.routes, (item) => { if (item.meta?.affix ?? false) { - arr.push(JSON.parse(JSON.stringify(item))) + arr.push(item) } }) tagList.value = arr