keepAlive缓存的使用,监听路由


1.缓存组件:

组件路由routers.js页面添加keepAlive:true

{
path: 'supplierList',
name: ' supplierList',
meta: {
title: '供应商列表',
keepAlive: true
},
component: () => import('@/view/data-base/supplierList')
},
supplierList.vue组件页面不需要做更改
如果想刷新页面可以添加监听路由事件
watch: {
 $route(to, from) {
 if (to.name === " supplierList") {//如果进入的页面name是 supplierList
//获取后端数据渲染当前页面  也就是刷新页面
this.queryFun(true);
}
 }
}
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM