修复多级页面关闭后再打开还缓存的bug

This commit is contained in:
zhigang.li 2018-12-27 15:20:13 +08:00
parent c336aef320
commit 0ee24af85e
3 changed files with 12 additions and 9 deletions

View File

@ -34,7 +34,7 @@
:key="`tag-nav-${index}`" :key="`tag-nav-${index}`"
:name="item.name" :name="item.name"
:data-route-item="item" :data-route-item="item"
@on-close="handleClose(item)" @on-close="close(item)"
@click.native="handleClick(item)" @click.native="handleClick(item)"
:closable="item.name !== $config.homeName" :closable="item.name !== $config.homeName"
:color="isCurrentTag(item) ? 'primary' : 'default'" :color="isCurrentTag(item) ? 'primary' : 'default'"

View File

@ -104,7 +104,8 @@ export default {
'setTagNavList', 'setTagNavList',
'addTag', 'addTag',
'setLocal', 'setLocal',
'setHomeRoute' 'setHomeRoute',
'closeTag'
]), ]),
...mapActions([ ...mapActions([
'handleLogin', 'handleLogin',
@ -140,6 +141,7 @@ export default {
this.$router.push(nextRoute) this.$router.push(nextRoute)
} }
} }
this.closeTag(route)
this.setTagNavList(res) this.setTagNavList(res)
}, },
handleClick (item) { handleClick (item) {

View File

@ -1,19 +1,20 @@
<template> <template>
<keep-alive :exclude="notCacheName"> <keep-alive :include="cacheList" :exclude="notCacheName">
<router-view ref="child"/> <router-view ref="child"/>
</keep-alive> </keep-alive>
</template> </template>
<script> <script>
export default { export default {
name: 'ParentView', name: 'ParentView',
data () {
return {
cacheChaildName: ''
}
},
computed: { computed: {
tagNavList () {
return this.$store.state.app.tagNavList
},
notCacheName () { notCacheName () {
return (this.$route.meta && this.$route.meta.notCache) ? this.$route.name : '' return [(this.$route.meta && this.$route.meta.notCache) ? this.$route.name : '']
},
cacheList () {
return ['ParentView', ...this.tagNavList.length ? this.tagNavList.filter(item => !(item.meta && item.meta.notCache)).map(item => item.name) : []]
} }
} }
} }