-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPageTitle.class.js
56 lines (52 loc) · 1.46 KB
/
PageTitle.class.js
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
export default {
name: 'pageTitle',
props: {
options: Object | String
},
data() {
return {
defaultTitle: ''
};
},
mounted() {
this.getCurrentRouterName();
},
methods: {
getCurrentRouterName() {
let _routers = this.$store.state.menuList;
let eachFn = data => {
for (let i = 0; i < data.length; i++) {
if (data[i].children && data[i].children.length) {
eachFn(data[i].children);
} else {
if (this.$route.path === data[i].path) {
this.defaultTitle = data[i].name;
break;
}
}
}
};
eachFn(_routers);
}
},
render(h) {
return (
<div class="page-title-view-wrap">
<div class="page-title-view-item">
<h4 class="page-title-view-wrap-name">
{this.options.name || this.defaultTitle}
{this.options.render && this.options.render(h, this)}
{(this.options.info || !this.options.render) && (
<div class="page-title-view-wrap-content">
<i class="el-icons-information" />
</div>
)}
</h4>
<div class="page-title-view-wrap-setting">{this.$slots.setting}</div>
</div>
{this.options.desRender && this.options.desRender(h, this)}
{this.$slots.historyRecord && <div class="page-title-view-wrap-hostory">{this.$slots.historyRecord}</div>}
</div>
);
}
};