情景:列表A,詳情B兔沃,列表搜索C。B→A额衙,需要緩存列表A,緩存正確窍侧,C→A转绷,A也被緩存,搜索不起作用斧账。
解決:
beforeRouteLeave(to,form,next){
if(to.name != 'alarmInfoSon'){
if(this.$vnode && this.$vnode.data.keepAlive){
// 第一種
var key = this.$vnode.parent.componentInstance.keys[0];
var cache = this.$vnode.parent.componentInstance.cache;
delete cache[key];
// 第二種
// this.$vnode.parent.componentInstance.cache={};
// this.$vnode.parent.componentInstance.keys=[];
// 第三種 搜索改成彈窗煞肾,在列表A中彈窗
}
}
next();
}