add view tabs
This commit is contained in:
@@ -4,14 +4,25 @@
|
||||
<router-link v-if='item.redirect==="noredirect"||index==levelList.length-1' to="" class="no-redirect">{{item.name}}</router-link>
|
||||
<router-link v-else :to="item.path">{{item.name}}</router-link>
|
||||
</el-breadcrumb-item>
|
||||
<router-link class="view-tabs" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path">
|
||||
<el-tag :closable="true" @close='closeViewTabs(tag,$event)'>
|
||||
{{tag.name}}
|
||||
</el-tag>
|
||||
</router-link>
|
||||
</el-breadcrumb>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
created() {
|
||||
this.getBreadcrumb()
|
||||
},
|
||||
computed: {
|
||||
visitedViews() {
|
||||
return this.$store.state.app.visitedViews.slice(-6)
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
levelList: null
|
||||
@@ -25,10 +36,18 @@
|
||||
matched = [{ name: '首页', path: '/' }].concat(matched)
|
||||
}
|
||||
this.levelList = matched;
|
||||
},
|
||||
closeViewTabs(view, $event) {
|
||||
this.$store.dispatch('delVisitedViews', view)
|
||||
$event.preventDefault()
|
||||
},
|
||||
addViewTabs() {
|
||||
this.$store.dispatch('addVisitedViews', this.$route.matched[this.$route.matched.length - 1])
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.addViewTabs();
|
||||
this.getBreadcrumb();
|
||||
}
|
||||
}
|
||||
@@ -46,4 +65,7 @@
|
||||
cursor:text;
|
||||
}
|
||||
}
|
||||
.view-tabs{
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user