Vue路由缓存页面

Vue切换路由数据缓存,

<keep-alive>
  <router-view></router-view>
</keep-alive>

index.js路由配置里添加meta

meta: {
       keepAlive: true
      }

然后再

true:缓存
false:不缓存

<keep-alive>
	<router-view v-if="$route.meta.keepAlive" class="Router"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive" class="Router"></router-view>