-
Notifications
You must be signed in to change notification settings - Fork 352
/
Copy pathSidebarLink.vue
64 lines (64 loc) · 1.12 KB
/
SidebarLink.vue
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
<template>
<component :is="tag"
@click.native="hideSidebar"
class="nav-item"
v-bind="$attrs"
tag="li">
<a class="nav-link">
<slot>
<i v-if="icon" :class="icon"></i>
<p>{{name}}</p>
</slot>
</a>
</component>
</template>
<script>
export default {
name: "sidebar-link",
inheritAttrs: false,
inject: {
autoClose: {
default: true
},
addLink: {
default: ()=>{}
},
removeLink: {
default: ()=>{}
}
},
props: {
name: String,
icon: String,
tag: {
type: String,
default: "router-link"
}
},
methods: {
hideSidebar() {
if (this.autoClose) {
this.$sidebar.displaySidebar(false);
}
},
isActive() {
return this.$el.classList.contains("active");
}
},
mounted() {
if (this.addLink) {
this.addLink(this);
}
},
beforeDestroy() {
if (this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el)
}
if (this.removeLink) {
this.removeLink(this);
}
}
};
</script>
<style>
</style>