8778b343
梁灏
init Menu components
|
1
|
<template>
|
7d0b7384
梁灏
fixed #3484
|
2
3
|
<a v-if="to" :href="linkUrl" :target="target" :class="classes" @click="handleClickItem" :style="itemStyle"><slot></slot></a>
<li v-else :class="classes" @click.stop="handleClickItem" :style="itemStyle"><slot></slot></li>
|
8778b343
梁灏
init Menu components
|
4
5
|
</template>
<script>
|
fd1582c5
梁灏
support Menu & La...
|
6
|
import Emitter from '../../mixins/emitter';
|
9932b935
梁灏
update
|
7
|
import { findComponentUpward } from '../../utils/assist';
|
acba45fe
zhigang.li
move computed val...
|
8
|
import mixin from './mixin';
|
7d0b7384
梁灏
fixed #3484
|
9
|
import mixinsLink from '../../mixins/link';
|
e05d7289
梁灏
update Menu
|
10
|
|
8cb84923
梁灏
update
|
11
12
|
const prefixCls = 'ivu-menu';
|
8778b343
梁灏
init Menu components
|
13
|
export default {
|
e05d7289
梁灏
update Menu
|
14
|
name: 'MenuItem',
|
7d0b7384
梁灏
fixed #3484
|
15
|
mixins: [ Emitter, mixin, mixinsLink ],
|
e05d7289
梁灏
update Menu
|
16
|
props: {
|
fd1582c5
梁灏
support Menu & La...
|
17
|
name: {
|
e05d7289
梁灏
update Menu
|
18
19
20
21
22
23
|
type: [String, Number],
required: true
},
disabled: {
type: Boolean,
default: false
|
7d0b7384
梁灏
fixed #3484
|
24
|
},
|
e05d7289
梁灏
update Menu
|
25
|
},
|
8778b343
梁灏
init Menu components
|
26
|
data () {
|
e05d7289
梁灏
update Menu
|
27
28
|
return {
active: false
|
b0893113
jingsam
add eslint
|
29
|
};
|
e05d7289
梁灏
update Menu
|
30
31
32
33
34
35
36
37
38
39
|
},
computed: {
classes () {
return [
`${prefixCls}-item`,
{
[`${prefixCls}-item-active`]: this.active,
[`${prefixCls}-item-selected`]: this.active,
[`${prefixCls}-item-disabled`]: this.disabled
}
|
b0893113
jingsam
add eslint
|
40
|
];
|
4bce7645
zhigang.li
make menu support...
|
41
|
},
|
4bce7645
zhigang.li
make menu support...
|
42
|
itemStyle () {
|
b2d676bd
zhigang.li
fixed the bug abo...
|
43
|
return this.hasParentSubmenu && this.mode !== 'horizontal' ? {
|
4bce7645
zhigang.li
make menu support...
|
44
45
|
paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px'
} : {};
|
e05d7289
梁灏
update Menu
|
46
|
}
|
8778b343
梁灏
init Menu components
|
47
|
},
|
e05d7289
梁灏
update Menu
|
48
|
methods: {
|
7d0b7384
梁灏
fixed #3484
|
49
|
handleClickItem (event) {
|
0acdae19
梁灏
update Menu
|
50
|
if (this.disabled) return;
|
fd1582c5
梁灏
support Menu & La...
|
51
|
|
4bce7645
zhigang.li
make menu support...
|
52
|
let parent = findComponentUpward(this, 'Submenu');
|
fd1582c5
梁灏
support Menu & La...
|
53
54
55
56
57
58
|
if (parent) {
this.dispatch('Submenu', 'on-menu-item-select', this.name);
} else {
this.dispatch('Menu', 'on-menu-item-select', this.name);
}
|
7d0b7384
梁灏
fixed #3484
|
59
60
|
this.handleCheckClick(event);
|
e05d7289
梁灏
update Menu
|
61
|
}
|
fd1582c5
梁灏
support Menu & La...
|
62
63
64
65
66
|
},
mounted () {
this.$on('on-update-active-name', (name) => {
if (this.name === name) {
this.active = true;
|
4bce7645
zhigang.li
make menu support...
|
67
|
this.dispatch('Submenu', 'on-update-active-name', name);
|
fd1582c5
梁灏
support Menu & La...
|
68
69
70
71
|
} else {
this.active = false;
}
});
|
e05d7289
梁灏
update Menu
|
72
|
}
|
b0893113
jingsam
add eslint
|
73
74
|
};
</script>
|