Commit d32beea1 authored by baiyaaaaa's avatar baiyaaaaa Committed by GitHub

fix menu active when route error (#9675)

parent fa55dbae
...@@ -243,7 +243,9 @@ ...@@ -243,7 +243,9 @@
} }
}, },
handleItemClick(item) { handleItemClick(item) {
let { index, indexPath } = item; const { index, indexPath } = item;
const oldActiveIndex = this.activeIndex;
this.activeIndex = item.index; this.activeIndex = item.index;
this.$emit('select', index, indexPath, item); this.$emit('select', index, indexPath, item);
...@@ -252,7 +254,10 @@ ...@@ -252,7 +254,10 @@
} }
if (this.router) { if (this.router) {
this.routeToItem(item); this.routeToItem(item, error => {
this.activeIndex = oldActiveIndex;
console.error(error);
});
} }
}, },
// 初始化展开菜单 // 初始化展开菜单
...@@ -271,10 +276,10 @@ ...@@ -271,10 +276,10 @@
submenu && this.openMenu(index, submenu.indexPath); submenu && this.openMenu(index, submenu.indexPath);
}); });
}, },
routeToItem(item) { routeToItem(item, onError) {
let route = item.route || item.index; let route = item.route || item.index;
try { try {
this.$router.push(route); this.$router.push(route, () => {}, onError);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment