vue2.0页面缓存和不缓存的方法

// 模板中:
<div class="home">
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>

</div> // 路由配置中: [
{
path: 'main',
name: 'main',
component: main,
meta: { keepAlive: false } // false为不缓存
},
{
path: 'orderSearch',
name: 'orderSearch',
component: orderSearch,
meta: { keepAlive: false } // false为不缓存
}
]

缓存与不缓存间可用:

如:从指定路由跳过来

watch: {
'$route' (to, from) {
if( from.path == "/home"){
//...
}
}
}

.

上一篇:ICDM 2007


下一篇:js bind es5函数柯里化