keep-alive 使用指南
需要使用的页面在路由文件里的 mate 标里加上keepAlive
h 和oldKeepAlive
两个值;如下:
//流水线
{
path: "/overview/tenant_manage/cicd/assemblyline",
name: "assemblyline",
component: () => import("@/views/cicd/assemblyline"),
meta: {
keepAlive: true, // 需要开启的路由
oldKeepAlive: true, // 需要开启的路由
namespace: true,
path: "/overview/tenant_manage/cicd/assemblyline"
}
},
// 流水线详情
{
path: "/overview/tenant_manage/cicd/lineDetails/:pipelineId/:projectId",
name: "lineDetails",
component: () => import("@/views/cicd/lineDetails"),
meta: {
keepAlive: false, // 不需要开启的路由
oldKeepAlive: false, // 不需要开启的路由
namespace: true,
path: "/overview/tenant_manage/cicd/assemblyline"
}
},
最后在需要激活的页面上加上生命周期函数activated
重新执行下created
方法,如:
activated() {}