a. I made it with vuex.
b. Change the value of default-active
in the route intercept.
c. Get this path from the navigation menu.
is fine in theory, but! The current page is not selected until
is refreshed. Direct click on the menu is not selected.
specific code
1.store
leftNavState: (state, data) => {
state.leftSelect = data;
},
2. Route interception
store.commit("leftNavState",to.path);
3.
in the navigation menu component <el-menu :default-active="leftSelect" class="leftMenue" router>
<el-menu-item :index="item.path" v-for="(item, index) in leftNav" :key="index">
<i class="iconfont" :class="item.icon"></i>
<span slot="title">{{item.name}}</span>
</el-menu-item>
</el-menu>
...mapState(["leftSelect"]),
...mapGetters(["leftNav"])