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

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

这样就可以了

相关推荐
m***56726 小时前
Win10下安装 Redis
数据库·redis·缓存
闲人编程6 小时前
Python的导入系统:模块查找、加载和缓存机制
java·python·缓存·加载器·codecapsule·查找器
-Xie-6 小时前
Redsi(十)——缓存双写
缓存
沐浴露z15 小时前
一张思维导图理清【Redis】
数据库·redis·缓存
-Xie-19 小时前
Redis(九)——BigKey与MoreKey
数据库·redis·缓存
秋邱1 天前
自我进化!AI 驱动平台自动迭代,用户行为 + 数据反馈打造教育超级助手 2.0
网络·数据库·人工智能·redis·python·缓存·docker
q***42052 天前
Redis如何设置密码
数据库·redis·缓存
一个尚在学习的计算机小白2 天前
springcache缓存
java·spring·缓存
工具人55552 天前
下载文件wget
数据库·redis·缓存
weixin_537765802 天前
【缓存技术】Redis核心原理解析
数据库·redis·缓存