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

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

这样就可以了

相关推荐
rannn_1113 小时前
【Redis|原理篇2】Redis网络模型、通信协议、内存回收
java·网络·redis·后端·缓存
志飞5 小时前
springboot配置可持久化本地缓存ehcache
java·spring boot·缓存·ehcache·ehcache持久化
下地种菜小叶7 小时前
行为采集、召回、排序、缓存怎么配合?一次讲透
缓存
chen_ever7 小时前
Redis详解|从基础到面试高频题
数据库·redis·后端·缓存
m0_737539378 小时前
redis的安装
数据库·redis·缓存
yuezhilangniao9 小时前
Redis 哨兵高可用集群完整文档-容器部署reids集群
数据库·redis·缓存
rleS IONS11 小时前
Redis五种用途
数据库·redis·缓存
China_Yanhy12 小时前
[Infra/SRE 知识库] AWS CloudFront API 边缘缓存配置与排障复盘
缓存·云计算·aws
YQ_0112 小时前
大幅提速 colcon build —— ccache 缓存 + 并行数控制防爆内存
linux·缓存·机器人·ros2
MY_TEUCK12 小时前
【Redis 高级实战】分布式缓存、 多级缓存与最佳实践一篇打通
redis·分布式·缓存