fix:levelbar&&tabsview bug
This commit is contained in:
parent
8211016078
commit
aaf24b4654
|
@ -21,7 +21,8 @@ const app = {
|
|||
if (state.visitedViews.some(v => v.path === view.path)) return
|
||||
state.visitedViews.push({
|
||||
name: view.name,
|
||||
path: view.path
|
||||
path: view.path,
|
||||
title: view.meta.title || 'no-name'
|
||||
})
|
||||
if (!view.meta.noCache) {
|
||||
state.cachedViews.push(view.name)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<sticky :className="'sub-navbar '+postForm.status">
|
||||
<template v-if="fetchSuccess">
|
||||
|
||||
<router-link style="margin-right:15px;" v-show='isEdit' :to="{ path:'create'}">
|
||||
<router-link style="margin-right:15px;" v-show='isEdit' :to="{ path:'create-form'}">
|
||||
<el-button type="info">创建form</el-button>
|
||||
</router-link>
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ export default {
|
|||
methods: {
|
||||
getBreadcrumb() {
|
||||
let matched = this.$route.matched.filter(item => item.name)
|
||||
if (matched.length === 0) {
|
||||
this.levelList = [{ path: '/', meta: { title: '首页' }}]
|
||||
return
|
||||
}
|
||||
const first = matched[0]
|
||||
if (first && (first.name !== '首页' || first.path !== '')) {
|
||||
matched = [{ path: '/', meta: { title: '首页' }}].concat(matched)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<template>
|
||||
<scroll-pane class='tabs-view-container'>
|
||||
<router-link class="tabs-view-item" :class="isActive(tag.path)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path"
|
||||
:key="tag.path">
|
||||
{{tag.name}}
|
||||
<router-link class="tabs-view-item" :class="isActive(tag)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path">
|
||||
{{tag.title}}
|
||||
<span class='el-icon-close' @click='closeViewTabs(tag,$event)'></span>
|
||||
</router-link>
|
||||
</scroll-pane>
|
||||
|
@ -20,7 +19,7 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('addVisitedViews', this.generateRoute())
|
||||
this.addViewTabs()
|
||||
},
|
||||
methods: {
|
||||
closeViewTabs(view, $event) {
|
||||
|
@ -37,17 +36,20 @@ export default {
|
|||
$event.preventDefault()
|
||||
},
|
||||
generateRoute() {
|
||||
if (this.$route.matched[this.$route.matched.length - 1].name) {
|
||||
return this.$route.matched[this.$route.matched.length - 1]
|
||||
if (this.$route.name) {
|
||||
return this.$route
|
||||
}
|
||||
this.$route.matched[0].path = '/'
|
||||
return this.$route.matched[0]
|
||||
return false
|
||||
},
|
||||
addViewTabs() {
|
||||
this.$store.dispatch('addVisitedViews', this.generateRoute())
|
||||
const route = this.generateRoute()
|
||||
if (!route) {
|
||||
return false
|
||||
}
|
||||
this.$store.dispatch('addVisitedViews', route)
|
||||
},
|
||||
isActive(path) {
|
||||
return path === this.$route.path
|
||||
isActive(route) {
|
||||
return route.path === this.$route.path || route.name === this.$route.name
|
||||
}
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue