Skip to content

Commit

Permalink
修复多级页面关闭后再打开还缓存的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lison16 committed Dec 27, 2018
1 parent c336aef commit 0ee24af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/main/components/tags-nav/tags-nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:key="`tag-nav-${index}`"
:name="item.name"
:data-route-item="item"
@on-close="handleClose(item)"
@on-close="close(item)"
@click.native="handleClick(item)"
:closable="item.name !== $config.homeName"
:color="isCurrentTag(item) ? 'primary' : 'default'"
Expand Down
4 changes: 3 additions & 1 deletion src/components/main/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export default {
'setTagNavList',
'addTag',
'setLocal',
'setHomeRoute'
'setHomeRoute',
'closeTag'
]),
...mapActions([
'handleLogin',
Expand Down Expand Up @@ -140,6 +141,7 @@ export default {
this.$router.push(nextRoute)
}
}
this.closeTag(route)
this.setTagNavList(res)
},
handleClick (item) {
Expand Down
15 changes: 8 additions & 7 deletions src/components/parent-view/parent-view.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<template>
<keep-alive :exclude="notCacheName">
<keep-alive :include="cacheList" :exclude="notCacheName">
<router-view ref="child"/>
</keep-alive>
</template>
<script>
export default {
name: 'ParentView',
data () {
return {
cacheChaildName: ''
}
},
computed: {
tagNavList () {
return this.$store.state.app.tagNavList
},
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) : []]
}
}
}
Expand Down

3 comments on commit 0ee24af

@Ken-twenty
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the params of handleClose and close are different, which could cause error when click close all btn, pls fix it :^) @lison16

@lovewxz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当标签只有两个的时候。关闭一个之后。再重新打开任然会有缓存 @lison16

@Hsyneve
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多级菜单设置两个子菜单,我把两个子菜单都关了,再打开,仍然是缓存的数据,关闭所有缓存的parentView下的子菜单时我把cachelist里面的parentView值去掉就没问题,再判断打开tab的时候,如果是缓存的子菜单再把parentView加上就没问题,但是感觉这个做法比较傻(后面四级或者更多级缓存的时候回该怎么办)。。。求大大给个好点的解决方案,谢谢啦@lison16

Please sign in to comment.