修改高亮保存,去掉bus

dev
e 3 years ago
parent a8695fd8bd
commit 45c1d97176
  1. 29
      src/components/common/Sidebar.vue

@ -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>

Loading…
Cancel
Save