Sfoglia il codice sorgente

feature/页面路由实现

dengrui 10 mesi fa
parent
commit
aeccb367c8
2 ha cambiato i file con 11 aggiunte e 3 eliminazioni
  1. 1 2
      src/layout/components/AppMain/index.vue
  2. 10 1
      src/views/layout/index.vue

+ 1 - 2
src/layout/components/AppMain/index.vue

@@ -2,7 +2,7 @@
   <section class="app-main">
     <div class="main-container">
       <router-view v-slot="{ Component, route }">
-        <keep-alive>
+        <keep-alive :include="cachedViews">
           <component :is="Component" :key="route.path" />
         </keep-alive>
       </router-view>
@@ -14,7 +14,6 @@
 import { useTagsViewStore } from "@/store";
 
 const cachedViews = computed(() => useTagsViewStore().cachedViews); // 缓存页面集合
-console.log(useTagsViewStore().cachedViews, "kep");
 </script>
 
 <style lang="scss" scoped>

+ 10 - 1
src/views/layout/index.vue

@@ -1,5 +1,14 @@
 <template>
   <div>
-    <router-view />
+    <router-view v-slot="{ Component, route }">
+      <keep-alive :include="cachedViews">
+        <component :is="Component" :key="route.fullPath" />
+      </keep-alive>
+    </router-view>
   </div>
 </template>
+<script setup lang="ts">
+import { useTagsViewStore } from "@/store";
+
+const cachedViews = computed(() => useTagsViewStore().cachedViews); // 缓存页面集合
+</script>