diff --git a/seller/src/libs/util.js b/seller/src/libs/util.js index 02af694b..62c905d7 100644 --- a/seller/src/libs/util.js +++ b/seller/src/libs/util.js @@ -360,6 +360,11 @@ util.initRouter = function (vm) { // 初始化路由 // 缓存数据 修改加载标识 window.localStorage.setItem('menuData', JSON.stringify(menuData)); vm.$store.commit('setAdded', true); + if(vm.$store.state.app.refMenu){ + vm.$nextTick(()=>{ + vm.$store.state.app.refMenu.updateActiveName(); + }); + } }) }; diff --git a/seller/src/store/modules/app.js b/seller/src/store/modules/app.js index a7efba23..ab987e70 100644 --- a/seller/src/store/modules/app.js +++ b/seller/src/store/modules/app.js @@ -40,9 +40,13 @@ const app = { tagsList: [...otherRouter.children], messageCount: 0, // 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js) - dontCache: ['test', 'test'] + dontCache: ['test', 'test'], + refMenu:"" }, mutations: { + childrenMenu(state,v){ + state.refMenu = v + }, // 动态添加主界面路由,需要缓存 updateAppRouter(state, routes) { state.routers.push(...routes); diff --git a/seller/src/views/main-components/shrinkable-menu/shrinkable-menu.vue b/seller/src/views/main-components/shrinkable-menu/shrinkable-menu.vue index fad57c20..1d60fb0a 100644 --- a/seller/src/views/main-components/shrinkable-menu/shrinkable-menu.vue +++ b/seller/src/views/main-components/shrinkable-menu/shrinkable-menu.vue @@ -33,6 +33,7 @@ import util from "@/libs/util.js"; export default { name: "shrinkableMenu", computed: { + // 二级菜单列表 menuList() { return this.$store.state.app.menuList; @@ -54,7 +55,7 @@ export default { this.selectNav(val.meta.firstRouterName) } } - } + } }, methods: { changeMenu(name) { //二级路由点击 @@ -63,12 +64,10 @@ export default { }); }, selectNav(name) { // 一级路由点击 + this.$store.commit("childrenMenu",this.$refs.childrenMenu) this.$store.commit("setCurrNav", name); this.setStore("currNav", name); util.initRouter(this); - this.$nextTick(()=>{ - this.$refs.childrenMenu.updateActiveName() - }) }, } };