|
|
|
@ -3,13 +3,13 @@ |
|
|
|
|
<el-menu |
|
|
|
|
class="sidebar-el-menu" |
|
|
|
|
:default-active="onRoutes" |
|
|
|
|
:collapse="collapse" |
|
|
|
|
background-color="#324157" |
|
|
|
|
text-color="#bfcbd9" |
|
|
|
|
active-text-color="#9278FF" |
|
|
|
|
unique-opened |
|
|
|
|
mode="horizontal" |
|
|
|
|
router |
|
|
|
|
@select="handleSelect" |
|
|
|
|
> |
|
|
|
|
<template v-for="item in items"> |
|
|
|
|
<template v-if="item.subs"> |
|
|
|
@ -51,11 +51,9 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import bus from '../common/bus'; |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
collapse: false, |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
icon: 'el-icon-lx-home', |
|
|
|
@ -90,17 +88,26 @@ export default { |
|
|
|
|
] |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
onRoutes() { |
|
|
|
|
return this.$route.path.replace('/', ''); |
|
|
|
|
watch:{ |
|
|
|
|
"$route.path":function(val){ |
|
|
|
|
this.items.map(e=>{ |
|
|
|
|
if(val.replace('/', '')===e.index){ |
|
|
|
|
this.handleSelect(val.replace('/', '')) |
|
|
|
|
this.$forceUpdate(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods:{ |
|
|
|
|
handleSelect(index){ |
|
|
|
|
this.onRoutes = index |
|
|
|
|
sessionStorage.setItem('sideBar',index) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
// 通过 Event Bus 进行组件间通信,来折叠侧边栏 |
|
|
|
|
bus.$on('collapse', msg => { |
|
|
|
|
this.collapse = msg; |
|
|
|
|
bus.$emit('collapse-content', msg); |
|
|
|
|
}); |
|
|
|
|
if(sessionStorage.getItem('sideBar')){ |
|
|
|
|
this.handleSelect(sessionStorage.getItem('sideBar')) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|