Browse Source

fix default-active bug

baiyaaaaa 8 years ago
parent
commit
1405b23ebb
3 changed files with 9 additions and 5 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      examples/docs/zh-cn/menu.md
  3. 6 4
      packages/menu/src/menu.vue

+ 2 - 0
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 属性

+ 1 - 1
examples/docs/zh-cn/menu.md

@@ -5,7 +5,7 @@
     }
     .el-menu-vertical-demo {
       width: 200px;
-      height: 400px;
+      min-height: 400px;
     }
     .line {
       height: 1px;

+ 6 - 4
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);
+      }
     }
   };
 </script>