网站首页 > 技术文章 正文
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 (64)
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- sqlset (64)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)