瀏覽代碼

menu item select event improve

baiyaaaaa 8 年之前
父節點
當前提交
0c75354eb5
共有 2 個文件被更改,包括 11 次插入5 次删除
  1. 6 1
      packages/menu/src/menu-item.vue
  2. 5 4
      packages/menu/src/menu.vue

+ 6 - 1
packages/menu/src/menu-item.vue

@@ -28,7 +28,12 @@
     },
     methods: {
       handleClick() {
-        this.rootMenu.handleSelect(this.index, this.indexPath, this.route || this.index);
+        this.rootMenu.handleSelect(
+          this.index,
+          this.indexPath,
+          this.route || this.index,
+          this
+        );
       }
     },
     created() {

+ 5 - 4
packages/menu/src/menu.vue

@@ -47,9 +47,10 @@
       defaultActive(value) {
         this.activeIndex = value;
         if (!this.menuItems[value]) return;
-        let indexPath = this.menuItems[value].indexPath;
+        let menuItem = this.menuItems[value];
+        let indexPath = menuItem.indexPath;
 
-        this.handleSelect(value, indexPath);
+        this.handleSelect(value, indexPath, null, menuItem);
       },
       defaultOpeneds(value) {
         this.openedMenus = value;
@@ -81,9 +82,9 @@
           this.$emit('open', index, indexPath);
         }
       },
-      handleSelect(index, indexPath, route) {
+      handleSelect(index, indexPath, route, instance) {
         this.activeIndex = index;
-        this.$emit('select', index, indexPath);
+        this.$emit('select', index, indexPath, instance);
 
         if (this.mode === 'horizontal') {
           this.broadcast('submenu', 'item-select', [index, indexPath]);