From 8c9246faa4185ad9d6c1500af40668c28e014d9c Mon Sep 17 00:00:00 2001 From: Yer <17633066053@163.com> Date: Wed, 16 Aug 2023 16:29:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E5=95=86?= =?UTF-8?q?=E5=AE=B6=E7=AB=AF=E8=8F=9C=E5=8D=95=E5=88=87=E6=8D=A2=E4=B9=8B?= =?UTF-8?q?=E5=90=8Eactive=E6=A0=B7=E5=BC=8F=E4=B8=A2=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seller/src/libs/util.js | 5 +++++ seller/src/store/modules/app.js | 6 +++++- .../main-components/shrinkable-menu/shrinkable-menu.vue | 7 +++---- 3 files changed, 13 insertions(+), 5 deletions(-) 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() - }) }, } };