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);
}
}
}