fix 面包屑组件 有重复项 自动隐藏
This commit is contained in:
parent
4f1ee1915a
commit
0bd7c2073b
@ -1,18 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-breadcrumb separator-class="el-icon-caret-right" class="app-breadcrumb">
|
<el-breadcrumb separator-class="el-icon-caret-right" class="app-breadcrumb">
|
||||||
<el-breadcrumb-item>
|
<el-breadcrumb-item>
|
||||||
<!-- <router-link to="/">飞机主控</router-link> -->
|
|
||||||
{{ $route.meta.tapName === "plane" ? "飞机主控" : "小程序后台" }}
|
{{ $route.meta.tapName === "plane" ? "飞机主控" : "小程序后台" }}
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
<el-breadcrumb-item v-for="(item, index) in breadcrumb" :key="index">
|
<el-breadcrumb-item
|
||||||
<!-- <router-link :to="item.path">{{ item.title }}</router-link> -->
|
v-for="(item, index) in filteredBreadcrumb"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
</el-breadcrumb>
|
</el-breadcrumb>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Breadcrumb',
|
name: 'Breadcrumb',
|
||||||
data () {
|
data () {
|
||||||
@ -29,7 +29,9 @@ export default {
|
|||||||
*/
|
*/
|
||||||
routes () {
|
routes () {
|
||||||
return this.$router.options.routes.filter(
|
return this.$router.options.routes.filter(
|
||||||
item => item.meta.hidden !== true && item.meta.roles.indexOf(this.$store.state.user.power.trim()) >= 0
|
item =>
|
||||||
|
item.meta.hidden !== true &&
|
||||||
|
item.meta.roles.indexOf(this.$store.state.user.power.trim()) >= 0
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -37,6 +39,16 @@ export default {
|
|||||||
*/
|
*/
|
||||||
presentPath () {
|
presentPath () {
|
||||||
return this.$route.path
|
return this.$route.path
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @description: 过滤重复的面包屑
|
||||||
|
*/
|
||||||
|
filteredBreadcrumb () {
|
||||||
|
const list = this.breadcrumb
|
||||||
|
if (list.length <= 1) return list
|
||||||
|
const last = list[list.length - 1]
|
||||||
|
const isDuplicate = list.slice(0, -1).some(item => item.title === last.title)
|
||||||
|
return isDuplicate ? [last] : list
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -79,7 +91,6 @@ export default {
|
|||||||
display: block !important;
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 当屏幕宽度小于等于480px时 */
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
.app-breadcrumb {
|
.app-breadcrumb {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
|
Loading…
Reference in New Issue
Block a user