vue__之keepalive

  1. 在开发中, 从列表跳到详情页面, 然后再返回到列表页 ,此时 列表回到了第一个
    如果想保持 列表的状态 ,不变, 这里就要用到 keep-alive;
  2. 没使用 keep-alive
    image
    table栏回到 第一个了
    image
  3. 使用 keep-alive 保持页面的状态;
  4. 首先在路由中的meta标签中记录keepAlive的属性为true
    image
  5. 在 home 打印一下 $route , 看是否有 meta 属性
    image

    image
  6. 在 App.js中 判断一下 router-view
    如果 路由里 有keepalive, 就使用保持状态的 路由,
    否则 就使用正常的路由
    image
  7. 使用 keep-alive后:
    image
    从详情页 返回 列表   没有发生改变
    image

猜你喜欢

转载自www.cnblogs.com/cl1998/p/13196518.html