|
1
2
3
4
5
6
7
8
9
10
11
|
<template>
<page-layout :desc="description" :title="getTitle" :link-list="linkList" :search="search" :tabs="tabs">
<div slot="extra" class="extra-img">
<img :src="extraImage"/>
</div>
<!-- keep-alive -->
<route-view ref="content"></route-view>
</page-layout>
</template>
<script>
|
|
12
13
|
import PageLayout from '../page/PageLayout'
import RouteView from './RouteView'
|
|
14
|
|
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
export default {
name: "PageContent",
components: {
RouteView,
PageLayout
},
data() {
return {
title: '',
description: '',
linkList: [],
extraImage: '',
search: false,
tabs: {}
}
},
mounted() {
this.getPageHeaderInfo()
},
updated() {
this.getPageHeaderInfo()
},
computed: {
|
|
38
|
|
|
39
40
41
|
getTitle() {
return this.$route.meta.title
}
|
|
42
|
|
|
43
44
45
46
47
48
49
|
},
methods: {
getPageHeaderInfo() {
// eslint-disable-next-line
this.title = this.$route.meta.title
// 因为套用了一层 route-view 所以要取 ref 对象下的子节点的第一个对象
const content = this.$refs.content && this.$refs.content.$children[0]
|
|
50
|
|
|
51
52
53
54
55
56
|
if (content) {
this.description = content.description
this.linkList = content.linkList
this.extraImage = content.extraImage
this.search = content.search == true ? true : false
this.tabs = content.tabs
|
|
57
58
59
|
}
}
}
|
|
60
|
}
|
|
61
62
63
|
</script>
<style lang="less" scoped>
|
|
64
65
66
67
68
69
70
71
72
73
74
|
.extra-img {
margin-top: -60px;
text-align: center;
width: 195px;
img {
width: 100%;
}
}
.mobile {
|
|
75
|
.extra-img {
|
|
76
|
margin-top: 0;
|
|
77
|
text-align: center;
|
|
78
|
width: 96px;
|
|
79
80
81
82
83
|
img {
width: 100%;
}
}
|
|
84
|
}
|
|
85
|
</style>
|