vue keep-alive 缓存组件

// 这是目前用的比较多的方式
<keep-alive>
    <router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
// 表示index和test2都使用keep-alive
routes: [
  { path: '/', redirect: '/index',  component: Index, meta: { keepAlive: true }},
  {
    path: '/common',
    component: TestParent,
    children: [
      { path: '/test2', component: Test2, meta: { keepAlive: true } }
    ]
  }
原文地址:https://www.cnblogs.com/yourName/p/10233015.html