Blame view

src/components/menu/menu-item.vue 1.09 KB
8778b343   梁灏   init Menu components
1
  <template>
e05d7289   梁灏   update Menu
2
      <li :class="classes" @click.stop="handleClick"><slot></slot></li>
8778b343   梁灏   init Menu components
3
4
  </template>
  <script>
e05d7289   梁灏   update Menu
5
6
      const prefixCls = 'ivu-menu';
  
8778b343   梁灏   init Menu components
7
      export default {
e05d7289   梁灏   update Menu
8
9
10
11
12
13
14
15
16
17
18
          name: 'MenuItem',
          props: {
              key: {
                  type: [String, Number],
                  required: true
              },
              disabled: {
                  type: Boolean,
                  default: false
              }
          },
8778b343   梁灏   init Menu components
19
          data () {
e05d7289   梁灏   update Menu
20
21
              return {
                  active: false
b0893113   jingsam   :art: add eslint
22
              };
e05d7289   梁灏   update Menu
23
24
25
26
27
28
29
30
31
32
          },
          computed: {
              classes () {
                  return [
                      `${prefixCls}-item`,
                      {
                          [`${prefixCls}-item-active`]: this.active,
                          [`${prefixCls}-item-selected`]: this.active,
                          [`${prefixCls}-item-disabled`]: this.disabled
                      }
b0893113   jingsam   :art: add eslint
33
                  ];
e05d7289   梁灏   update Menu
34
              }
8778b343   梁灏   init Menu components
35
          },
e05d7289   梁灏   update Menu
36
37
          methods: {
              handleClick () {
0acdae19   梁灏   update Menu
38
                  if (this.disabled) return;
e05d7289   梁灏   update Menu
39
40
41
                  this.$dispatch('on-menu-item-select', this.key);
              }
          }
b0893113   jingsam   :art: add eslint
42
43
      };
  </script>