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里面把这三个路由写出来

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

这样就可以了

相关推荐
2601_962128412 小时前
SpringBoot篇(缓存层)
java·spring boot·缓存
mmsy10243 小时前
缓存知识点总结
java·spring·缓存
garmin Chen5 小时前
redis面试题
java·数据库·redis·缓存
程序员夏洛12 小时前
Redis 的 Red Lock 是什么?你了解吗?
数据库·redis·缓存
智购科技智能售货柜1 天前
2026自动售货机设备能耗计量系统:从功率监测到能效分析的工程实践~YH
数据库·人工智能·redis·缓存·架构·perl·symfony
潘正翔1 天前
Memcached构建缓存服务器
运维·服务器·数据库·缓存·云原生·memcached
Jul1en_1 天前
【Java 脚手架】封装通用工具类-3
java·开发语言·redis·缓存·ai·bootstrap·rabbitmq
李昊哲小课1 天前
Spring Boot 4 旅游主题实战教程 阶段四:缓存与底层进阶
spring boot·redis·缓存·性能优化·log4j·旅游·性能
杨运交1 天前
[065][缓存模块]Hibernate二级缓存自定义实现:基于Spring Cache的多级缓存适配器
spring·缓存·hibernate
上火的金鱼妹1 天前
redis集群部署与连接
数据库·redis·缓存