fix: 🐛 修复商家端菜单切换之后active样式丢失问题

master
Yer 2023-08-16 16:29:45 +08:00
parent 74b180f6d3
commit 8c9246faa4
3 changed files with 13 additions and 5 deletions

View File

@ -360,6 +360,11 @@ util.initRouter = function (vm) { // 初始化路由
// 缓存数据 修改加载标识 // 缓存数据 修改加载标识
window.localStorage.setItem('menuData', JSON.stringify(menuData)); window.localStorage.setItem('menuData', JSON.stringify(menuData));
vm.$store.commit('setAdded', true); vm.$store.commit('setAdded', true);
if(vm.$store.state.app.refMenu){
vm.$nextTick(()=>{
vm.$store.state.app.refMenu.updateActiveName();
});
}
}) })
}; };

View File

@ -40,9 +40,13 @@ const app = {
tagsList: [...otherRouter.children], tagsList: [...otherRouter.children],
messageCount: 0, messageCount: 0,
// 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js) // 在这里定义你不想要缓存的页面的name属性值(参见路由配置router.js)
dontCache: ['test', 'test'] dontCache: ['test', 'test'],
refMenu:""
}, },
mutations: { mutations: {
childrenMenu(state,v){
state.refMenu = v
},
// 动态添加主界面路由,需要缓存 // 动态添加主界面路由,需要缓存
updateAppRouter(state, routes) { updateAppRouter(state, routes) {
state.routers.push(...routes); state.routers.push(...routes);

View File

@ -33,6 +33,7 @@ import util from "@/libs/util.js";
export default { export default {
name: "shrinkableMenu", name: "shrinkableMenu",
computed: { computed: {
// //
menuList() { menuList() {
return this.$store.state.app.menuList; return this.$store.state.app.menuList;
@ -63,12 +64,10 @@ export default {
}); });
}, },
selectNav(name) { // selectNav(name) { //
this.$store.commit("childrenMenu",this.$refs.childrenMenu)
this.$store.commit("setCurrNav", name); this.$store.commit("setCurrNav", name);
this.setStore("currNav", name); this.setStore("currNav", name);
util.initRouter(this); util.initRouter(this);
this.$nextTick(()=>{
this.$refs.childrenMenu.updateActiveName()
})
}, },
} }
}; };