网站首页 > 技术文章 正文
app.vue 入口页面
<keep-alive :include="includedComponents">
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
import {mapGetters} from 'vuex';
computed: mapGetters(['includedComponents'])
路由配置:加meta
{
path:'arrive',
name:'到达',
meta:{keepAlive:true} //如果需要用keep-alive 缓存的话,必须使用name 去跳转路由
components:''
}
arrive.vue需要缓存的页面:
beforeRouteLeave(to,from,next){
if(to.name == '') //判断是加缓存还是清理掉缓存
this.$store.dispatch('setCache',this.$options.name) //加缓存 或者 this.$options.name = "arrive"
this.$store.dispatch('clearCache','arrive') //清理缓存 或者 this.$options.name = "arrive"
}
vuex页面截图;
猜你喜欢
- 2024-10-17 vue进阶系列——用typescript玩转vue和vuex
- 2024-10-17 百度Web前端开发实战案例解析(web前端开发案例教程)
- 2024-10-17 vue之vuex状态管理(vuex状态属性)
- 2024-10-17 从身份证号中截取出生日期(从身份证号截取出生年月日)
- 2024-10-17 websocket长连接和公共状态管理方案
- 2024-10-17 带你五步学会Vue SSR(vue sse)
- 2024-10-17 vue-element-admin 登陆(vue elements admin)
- 2024-10-17 Vue实现动态路由(vue动态路由三种方法)
- 2024-10-17 吃透 Vue 项目开发实践|16个方面深入前端工程化开发技巧【中】
- 2024-10-17 vue常见组件有哪些(vue的组件有哪些)
- 最近发表
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- apt-getinstall-y (100)
- node_modules怎么生成 (87)
- chromepost (71)
- flexdirection (73)
- c++int转char (80)
- mysqlany_value (79)
- static函数和普通函数 (84)
- el-date-picker开始日期早于结束日期 (76)
- js判断是否是json字符串 (75)
- c语言min函数头文件 (77)
- asynccallback (71)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 无效的列索引 (74)