PageView.vue 1.6 KB

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