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

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

这样就可以了

相关推荐
Hello.Reader21 分钟前
Redis 延迟监控深度指南
数据库·redis·缓存
Hello.Reader5 小时前
Redis 延迟排查与优化全攻略
数据库·redis·缓存
在肯德基吃麻辣烫18 小时前
《Redis》缓存与分布式锁
redis·分布式·缓存
先睡1 天前
Redis的缓存击穿和缓存雪崩
redis·spring·缓存
CodeWithMe2 天前
【Note】《深入理解Linux内核》 Chapter 15 :深入理解 Linux 页缓存
linux·spring·缓存
大春儿的试验田2 天前
高并发收藏功能设计:Redis异步同步与定时补偿机制详解
java·数据库·redis·学习·缓存
likeGhee2 天前
python缓存装饰器实现方案
开发语言·python·缓存
C182981825752 天前
OOM电商系统订单缓存泄漏,这是泄漏还是溢出
java·spring·缓存
西岭千秋雪_2 天前
Redis性能优化
数据库·redis·笔记·学习·缓存·性能优化
en-route2 天前
HTTP 缓存
网络协议·http·缓存