2021-07-16

keep-alive 使用指南

需要使用的页面在路由文件里的 mate 标里加上keepAliveh 和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() {}

你可能感兴趣的:(2021-07-16)