web页面缓存最佳实践

更多请查考vue2.0 keep-alive最佳实践

(1)使用router. meta属性

// 这是目前用的比较多的方式

    


router设置

... 
  routes: [
    { path: '/', redirect: '/index',  component: Index, meta: { keepAlive: true }},
    {
      path: '/common',
      component: TestParent,
      children: [
        { path: '/test2', component: Test2, meta: { keepAlive: true } } 
      ]
    }
    ....
    // 表示index和test2都使用keep-alive

你可能感兴趣的:(web页面缓存最佳实践)