Commit 7ebf0329 authored by 李苏's avatar 李苏 💬

还原

parent 445935fb
<template>
<section class="app-main">
<keep-alive >
<router-view v-show="isCache" />
<transition name="fade-transform" mode="out-in">
<keep-alive v-if="cachedViews.includes(key)" >
<router-view :key="key" />
</keep-alive>
<router-view v-if="!isCache" />
<router-view v-else :key="key" />
</transition>
</section>
</template>
......@@ -15,59 +16,9 @@ export default {
cachedViews() {
return this.$store.state.tagsView.cachedViews
},
},
watch:{
isCache(val){
console.log(val)
},
cachedViews(val){
this.JSONcachedViews=JSON.stringify(val)
},
JSONcachedViews(nv,ov){
let nvobj=JSON.parse(nv)
let ovobj=JSON.parse(ov)
this.oldCachedViews=ovobj
if(nvobj.length>ovobj.length){
this.addBz=true
}else{
this.addBz=false
}
},
$route(val){
this.key=val.name
if(this.addBz){
if(this.oldCachedViews.includes(val.name)){
this.isCache=true
}else{
this.isCache=false
}
// if(this.oldCachedViews.includes(val.name)){
// this.isCache=true
// }else{
// this.isCache=false
// }
this.addBz=false
}else{
// this.isCache=true
if(this.cachedViews.includes(val.name)){
console.log('包含,进入缓存')
this.isCache=true
}else{
console.log('不包含,不进入缓存')
this.isCache=false
}
// this.isCache=this.cachedViews.includes(val.name)
}
}
},
data(){
return{
isCache:true,
JSONcachedViews:'',
addBz:false,
key:null,
oldCachedViews:[]
key() {
console.log(this.$route.name)
return this.$route.name
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment