-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path-breadcrumb.vue
executable file
·59 lines (57 loc) · 1.67 KB
/
-breadcrumb.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
<template>
<div id="member-breadcrumb" class="w">
<a href="/"><i class="iconfont ea-icon-home"></i>Home</a>>
<nuxt-link to="/member">Your Account</nuxt-link>>
<template v-if="fullPath === '/member'">
<nuxt-link to="/member/my-profile"> {{ $store.getters.user.uname }}</nuxt-link>
</template>
<template v-else v-for="(b, i) in breadcrumbs">
<nuxt-link :to="b.path" :key="b.path"> {{ b.title }}</nuxt-link>
<template v-if="i !== breadcrumbs.length - 1">></template>
</template>
</div>
</template>
<script>
import menus from './menus'
export default {
name: 'member-breadcrumb',
computed: {
fullPath() {
return this.$route.fullPath
},
breadcrumbs() {
let _name = this.$route.name
let _paths = this.$route.path.split('/').slice(2, 6)
let _bcs = []
menus.forEach(item => {
item.children.forEach(_item => {
if (_item.name === _paths[0]) {
_bcs.push({ title: _item.title, path: '/member/' + _item.path })
if (_item.children) {
_item.children.forEach(__item => {
if (__item.name === _paths[1]) _bcs.push({ title: __item.title, path: '/member/' + _item.path })
})
}
}
})
})
return _bcs
}
}
}
</script>
<style type="text/scss" lang="scss" scoped>
@import "../../assets/styles/color";
#member-breadcrumb {
position: relative;
font-size: 12px;
height: 20px;
padding: 10px 0;
color: #777;
.iconfont {
margin-right: 5px;
}
a { color: #666 }
a:hover { color: $color-main }
}
</style>