Skip to content

Commit 8608ee5

Browse files
authored
Merge pull request lin-xin#153 from lin-xin/dev
增加关闭当前标签页的方法
2 parents 05d6a7b + 4ff06b7 commit 8608ee5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules
33
/dist
44
example.html
5+
favicon.ico
56
# local env files
67
.env.local
78
.env.*.local

src/components/common/Tags.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@
8989
},
9090
created(){
9191
this.setTags(this.$route);
92+
// 监听关闭当前页面的标签页
93+
bus.$on('close_current_tags', () => {
94+
for (let i = 0, len = this.tagsList.length; i < len; i++) {
95+
const item = this.tagsList[i];
96+
if(item.path === this.$route.fullPath){
97+
if(i < len - 1){
98+
this.$router.push(this.tagsList[i+1].path);
99+
}else if(i > 0){
100+
this.$router.push(this.tagsList[i-1].path);
101+
}else{
102+
this.$router.push('/');
103+
}
104+
this.tagsList.splice(i, 1);
105+
}
106+
}
107+
})
92108
}
93109
}
94110

0 commit comments

Comments
 (0)