From ef06717f64bc1a54c10b6549948056669ab5a85c Mon Sep 17 00:00:00 2001 From: baiyaaaaa Date: Fri, 13 Jan 2017 18:44:10 +0800 Subject: [PATCH] fix first enter do not active the menu bug (#2399) --- packages/menu/src/menu.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/menu/src/menu.vue b/packages/menu/src/menu.vue index 79af36c33..0ae67a4ad 100644 --- a/packages/menu/src/menu.vue +++ b/packages/menu/src/menu.vue @@ -57,6 +57,15 @@ }, defaultOpeneds(value) { this.openedMenus = value; + }, + '$route': { + immediate: true, + handler(value) { + if (this.router) { + this.activedIndex = value.path; + this.initOpenedMenu(); + } + } } }, methods: { @@ -100,7 +109,7 @@ }, handleItemClick(item) { let { index, indexPath } = item; - this.activedIndex = item.index; + this.$emit('select', index, indexPath, item); if (this.mode === 'horizontal') { @@ -109,6 +118,8 @@ if (this.router) { this.routeToItem(item); + } else { + this.activedIndex = item.index; } }, // 初始化展开菜单