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