Item.vue
752 Bytes
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
<template>
<span>
<svg-icon v-if="icon" className="icon" :icon-class="ComIcon" />
<span v-if="title" slot="title">{{ title }}</span>
</span>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'MenuItem',
props: {
icon: {
type: String,
default: ''
},
title: {
type: String,
default: ''
},
item: {
type: Object
}
},
computed: {
...mapState('permission', ['routes']),
ComIcon() {
const { path } = this.$route
if (path.indexOf(this.item.path) > -1) {
return `${this.icon}-active`
} else {
return this.icon
}
}
}
}
</script>
<style lang="scss" scoped>
.icon {
width: 14px;
height: 14px;
}
</style>