keep-alive缓存三级及三级以上路由

需求需要缓存这个出入记录,当tab切换时不重新加载,当刷新页面时,或把这个关闭在重新打开时重新加载如图:

(我这里用的是芋道源码的前端框架)

keep-alive

1、include 包含页面组件name的这些组件页面,会被缓存起来

2、exclude 除了这些name以外的页面组件,会被缓存起来

3、没有include或者exclude属性,表示所有的路由组件都会被缓存起来

复制代码
<template>
  <section class="app-main">
    <transition name="fade-transform" mode="out-in">
      <keep-alive :include="cachedViews" exclude="redirect">
        <router-view :key="key" />
      </keep-alive>
    </transition>
  </section>
</template>

<script>
export default {
  name: 'AppMain',
  computed: {
    cachedViews() {
      return this.$store.state.tagsView.cachedViews
    },
    key() {
      return this.$route.path
    }
  }
}
</script>

解决方法

现在router里面的index.js里面把这三个路由写出来

然后在仓库里面手动把二级路由加上

这样就可以了

相关推荐
Lucky小小吴8 小时前
开源项目解读4-高性能并发缓存库Ristretto
缓存·开源·高并发·高性能缓存·实时数据处理·ristretto·tinylfu
亮子AI11 小时前
【NestJS】在 nest.js 项目中,如何使用 Postgresql 来做缓存?
开发语言·缓存·node.js·nest.js
好大的月亮12 小时前
oss中的文件替换后chrome依旧下载到缓存文件概述
前端·chrome·缓存
CodeAmaz14 小时前
SpringBoot两级缓存实现
spring boot·spring·缓存
小丁爱养花1 天前
Redis 内部编码/单线程模型/string
数据库·redis·缓存·1024程序员节
爬山算法1 天前
Redis(84)如何解决Redis的缓存击穿问题?
java·redis·缓存
Merlos_wind1 天前
【Redis典型应用——缓存详解】
数据库·redis·缓存
缘友一世1 天前
LLama 3分组查询注意力与KV缓存机制
人工智能·深度学习·缓存·transformer·llama·gqa·kv缓存
阿祥~2 天前
windows 安装 Redis
数据库·redis·缓存
emma羊羊2 天前
【Redis】
数据库·redis·缓存