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

还原

parent 445935fb
<template> <template>
<section class="app-main"> <section class="app-main">
<keep-alive > <transition name="fade-transform" mode="out-in">
<router-view v-show="isCache" /> <keep-alive v-if="cachedViews.includes(key)" >
<router-view :key="key" />
</keep-alive> </keep-alive>
<router-view v-if="!isCache" /> <router-view v-else :key="key" />
</transition>
</section> </section>
</template> </template>
...@@ -15,59 +16,9 @@ export default { ...@@ -15,59 +16,9 @@ export default {
cachedViews() { cachedViews() {
return this.$store.state.tagsView.cachedViews return this.$store.state.tagsView.cachedViews
}, },
}, key() {
watch:{ console.log(this.$route.name)
isCache(val){ return this.$route.name
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:[]
} }
} }
} }
......
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