From 1405b23ebbb602fc9bd9094a61f8578b94b91f64 Mon Sep 17 00:00:00 2001 From: baiyaaaaa Date: Tue, 4 Oct 2016 20:10:57 +0800 Subject: [PATCH] fix default-active bug --- CHANGELOG.md | 2 ++ examples/docs/zh-cn/menu.md | 2 +- packages/menu/src/menu.vue | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2e1c108..ed5ca483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - 修复 Tabs 切换后 Tab-panel 被销毁的问题 - 修复 TimePicker 错误的隐藏面板 - 修复 Table Cell 的样式, #204 +- 修复 Menu default-active 属性不能为空的问题, #200 +- 修复 Menu unique-opened 开启后无法展开子菜单的问题, #200 - 为 Notification 和 Message 的不同 type 添加独立的调用方法 - 为 Message Box 和 Dialog 添加 lockScroll 属性,用于定义是否在弹框出现时将 body 滚动锁定 - 新增 Input textarea 类型的 rows, autosize 属性 diff --git a/examples/docs/zh-cn/menu.md b/examples/docs/zh-cn/menu.md index 0f36bbee..05589ff2 100644 --- a/examples/docs/zh-cn/menu.md +++ b/examples/docs/zh-cn/menu.md @@ -5,7 +5,7 @@ } .el-menu-vertical-demo { width: 200px; - height: 400px; + min-height: 400px; } .line { height: 1px; diff --git a/packages/menu/src/menu.vue b/packages/menu/src/menu.vue index 0a26e323..dd3a2728 100644 --- a/packages/menu/src/menu.vue +++ b/packages/menu/src/menu.vue @@ -64,11 +64,11 @@ let openedMenus = this.openedMenus; if (openedMenus.indexOf(index) !== -1) return; if (this.uniqueOpened) { - openedMenus = openedMenus.filter(index => { + this.openedMenus = openedMenus.filter(index => { return indexPath.indexOf(index) !== -1; }); } - openedMenus.push(index); + this.openedMenus.push(index); }, closeMenu(index, indexPath) { this.openedMenus.splice(this.openedMenus.indexOf(index), 1); @@ -106,9 +106,11 @@ }, mounted() { let index = this.activeIndex; - let indexPath = this.menuItems[index].indexPath; + if (index) { + let indexPath = this.menuItems[index].indexPath; - this.handleSelect(index, indexPath); + this.handleSelect(index, indexPath); + } } };