浏览代码

Merge pull request #196 from dnshi/menu-item-route

menu-item: add menu item route property
杨奕 8 年之前
父节点
当前提交
b4d800ec41
共有 3 个文件被更改,包括 8 次插入3 次删除
  1. 1 0
      examples/docs/zh-cn/menu.md
  2. 5 1
      packages/menu/src/menu-item.vue
  3. 2 2
      packages/menu/src/menu.vue

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

@@ -172,6 +172,7 @@
 | 参数      | 说明    | 类型      | 可选值       | 默认值   |
 |---------- |-------- |---------- |-------------  |-------- |
 | index     | 唯一标志   | string  | — | — |
+| route     | Vue Router 路径对象 | Object | — | — |
 
 ### Menu-Group Attribute
 | 参数      | 说明    | 类型      | 可选值       | 默认值   |

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

@@ -12,6 +12,10 @@
         type: String,
         required: true
       },
+      route: {
+        type: Object,
+        required: false
+      },
       disabled: {
         type: Boolean,
         required: false
@@ -24,7 +28,7 @@
     },
     methods: {
       handleClick() {
-        this.rootMenu.handleSelect(this.index, this.indexPath);
+        this.rootMenu.handleSelect(this.index, this.indexPath, this.route);
       }
     },
     created() {

+ 2 - 2
packages/menu/src/menu.vue

@@ -84,7 +84,7 @@
           this.$emit('open', index, indexPath);
         }
       },
-      handleSelect(index, indexPath) {
+      handleSelect(index, indexPath, route) {
         this.activeIndex = index;
         this.$emit('select', index, indexPath);
 
@@ -100,7 +100,7 @@
         }
 
         if (this.router) {
-          this.$router.push(index);
+          this.$router.push(route || index);
         }
       }
     },