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