Bread.vue
1.3 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
<template>
<div class='bread'>
<strong>
{{strong}}
</strong>
<Breadcrumb separator="/" class='el-bread'>
<Breadcrumb-item href="{ path: '/' }">首页</Breadcrumb-item>
<Breadcrumb-item v-for='(item,index) in $route.matched'>{{item.name}}</Breadcrumb-item>
</Breadcrumb>
</div>
</template>
<script>
export default {
name: 'bread',
data () {
return {
strong:''
}
},
methods:{
getPageText(name){
return name=name.replace('编辑',this.$route.query.id ? '修改' : '添加');
}
},
mounted(){
},
created(){
if (this.$route.matched.length) {
var name=this.$route.matched[this.$route.matched.length-1].name;
this.strong=this.getPageText(name);
}
},
watch:{
$route(to,from){
this.strong=this.getPageText(to.name);
}
}
}
</script>
<style scoped lang='less'>
.bread{
height: 40px;
line-height: 26px;
.el-bread{
display: inline-block;
float: right;
text-align: right;
line-height: 26px;
}
}
</style>