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

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

这样就可以了

相关推荐
大侠归来1 小时前
Redis Cluster 的 16384 个槽(Slot)是什么?
数据库·redis·缓存
xixingzhe22 小时前
秒杀库存三种缓存实现方案
数据库·redis·缓存
lv__pf4 小时前
redis【TL redis(6)】
数据库·redis·缓存
hweiyu005 小时前
Redis命令:RPOPLPUSH
redis·缓存
霸道流氓气质6 小时前
Redisson BloomFilter:分布式位图实现、误判率调优与缓存穿透三级防护的 Spring Boot 生产级实战
spring boot·分布式·缓存
wefg120 小时前
【Redis】安装与启动
数据库·redis·缓存
大圣编蚕20 小时前
常见的 Redis 面试题(高频整理)
数据库·redis·缓存
梅菲塔亚1 天前
博客_Redis入门到实战
数据库·redis·缓存
蓝胖的四次元口袋1 天前
Redis 知识梳理(3)
数据库·redis·缓存
青春不朽5121 天前
Python 里 a is b 有时 True 有时 False?小整数缓存和常量折叠的底层真相
python·spring·缓存