PageView.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <page-layout :desc="description" :title="getTitle" :link-list="linkList">
  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 './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. }
  26. },
  27. mounted () {
  28. this.getPageHeaderInfo()
  29. },
  30. updated () {
  31. this.getPageHeaderInfo()
  32. },
  33. computed: {
  34. getTitle () {
  35. return this.$route.meta.title
  36. }
  37. },
  38. methods: {
  39. getPageHeaderInfo () {
  40. // eslint-disable-next-line
  41. this.title = this.$route.meta.title
  42. // 因为套用了一层 route-view 所以要取 ref 对象下的子节点的第一个对象
  43. const content = this.$refs.content && this.$refs.content.$children[0]
  44. if (content) {
  45. this.description = content.description
  46. this.linkList = content.linkList
  47. this.extraImage = content.extraImage
  48. }
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .extra-img {
  55. margin-top: -60px;
  56. text-align: center;
  57. width: 195px;
  58. img {
  59. width: 100%;
  60. }
  61. }
  62. .mobile {
  63. .extra-img{
  64. margin-top: 0;
  65. text-align: center;
  66. width: 96px;
  67. img{
  68. width: 100%;
  69. }
  70. }
  71. }
  72. </style>