Repository navigation
Expand file tree
/
Copy pathmenu-item.vue
More file actions
112 lines (107 loc) · 2.16 KB
/
Copy pathmenu-item.vue
File metadata and controls
112 lines (107 loc) · 2.16 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<template>
<li
:key="index"
class="layui-nav-item"
:class="{
'layui-nav-itemed': isActive
}"
@mouseleave="onMouseLeave"
@mouseenter="onMouseEnter"
>
<a
href="javascript:;"
@click="handleClick"
>
<i
v-if="icon"
:class="'layui-icon layui-icon-' + icon"
/>
{{ title }}
<slot
v-if="!title"
name="title"
/>
<span
v-if="$slots.default"
class="layui-nav-more"
/>
</a>
<dl
v-if="$slots.default"
class="layui-nav-child"
:class="rootMenu.mode"
>
<slot />
</dl>
</li>
</template>
<script>
import eventHub from '@/mixins/eventHub';
export default {
name: 'LayMenuItem',
mixins: [eventHub],
props: {
index: {
type: Number,
required: true
},
title: {
type: String,
default: ''
},
icon: {
type: String,
default: ''
}
},
inject: ['rootMenu'],
computed: {
isActive () {
const isActive =
this.rootMenu.openeds.findIndex(o => o == this.index) != -1;
return isActive;
},
isVertical () {
return this.rootMenu.mode == 'vertical';
}
},
methods: {
handleClick () {
if (this.$slots.default && this.rootMenu.mode == 'vertical') {
this.eventEmit('menu-item-click', this);
}
},
onMouseEnter () {
if (this.$slots.default && this.rootMenu.mode == 'horizontal') {
this.eventEmit('menu-item-click', this);
}
},
onMouseLeave () {
if (this.$slots.default && this.rootMenu.mode == 'horizontal') {
this.eventEmit('menu-item-click', this);
}
}
}
};
</script>
<style scoped>
.layui-nav .layui-nav-item a.layui-nav-item-bar-l,
.layui-nav .layui-nav-item a.layui-nav-item-bar-b {
transition-duration: 0s;
}
.layui-nav-item-bar-l:hover {
border-left: 5px solid rgb(0, 150, 136);
padding-left: 15px;
}
.layui-nav-item-bar-b:hover {
border-bottom: 5px solid rgb(0, 150, 136);
padding-top: 5px;
line-height: 50px;
}
.layui-nav-itemed > .layui-nav-child.horizontal {
background: #fff !important;
}
.layui-icon {
margin-right: 5px;
}
</style>