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);
}
 }
}
 
posted @ 2019-07-10 10:56  苏小白啊  阅读(1525)  评论(0编辑  收藏  举报