component.tpl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <style>
  2. .page-component {
  3. padding-bottom: 95px;
  4. box-sizing: border-box;
  5. .content {
  6. margin-left: -1px;
  7. > {
  8. h3 {
  9. margin: 45px 0 15px;
  10. }
  11. table {
  12. border-collapse: collapse;
  13. width: 100%;
  14. background-color: #fff;
  15. color: #5e6d82;
  16. font-size: 14px;
  17. margin-bottom: 45px;
  18. line-height: 1.5em;
  19. strong {
  20. font-weight: normal;
  21. }
  22. th {
  23. text-align: left;
  24. border-top: 1px solid #eaeefb;
  25. background-color: #EFF2F7;
  26. white-space: nowrap;
  27. }
  28. td, th {
  29. border-bottom: 1px solid #eaeefb;
  30. padding: 10px;
  31. max-width: 250px;
  32. }
  33. th:first-child, td:first-child {
  34. padding-left: 10px;
  35. }
  36. }
  37. }
  38. }
  39. .page-component-up {
  40. background-color: #58b7ff;
  41. position: fixed;
  42. right: 100px;
  43. bottom: 150px;
  44. size: 50px;
  45. border-radius: 25px;
  46. cursor: pointer;
  47. opacity: 0.4;
  48. transition: .3s;
  49. i {
  50. color: #fff;
  51. display: block;
  52. line-height: 50px;
  53. text-align: center;
  54. font-size: 22px;
  55. }
  56. &.hover {
  57. opacity: 1;
  58. }
  59. }
  60. .back-top-fade-enter,
  61. .back-top-fade-leave-active {
  62. transform: translateY(-30px);
  63. opacity: 0;
  64. }
  65. }
  66. </style>
  67. <template>
  68. <div class="page-container page-component">
  69. <el-row>
  70. <el-col :xs="24" :sm="6">
  71. <side-nav :data="navsData[lang]" :base="`/${ lang }/component`"></side-nav>
  72. </el-col>
  73. <el-col :xs="24" :sm="18">
  74. <router-view class="content"></router-view>
  75. <footer-nav></footer-nav>
  76. </el-col>
  77. </el-row>
  78. <transition name="back-top-fade">
  79. <div
  80. class="page-component-up"
  81. :class="{ 'hover': hover }"
  82. v-show="showBackToTop"
  83. @mouseenter="hover = true"
  84. @mouseleave="hover = false"
  85. @click="toTop">
  86. <i class="el-icon-caret-top"></i>
  87. </div>
  88. </transition>
  89. </div>
  90. </template>
  91. <script>
  92. import navsData from '../../nav.config.json';
  93. import throttle from 'throttle-debounce/throttle';
  94. export default {
  95. data() {
  96. return {
  97. lang: this.$route.meta.lang,
  98. navsData,
  99. hover: false,
  100. showBackToTop: false
  101. };
  102. },
  103. methods: {
  104. toTop() {
  105. this.hover = false;
  106. this.showBackToTop = false;
  107. document.body.scrollTop = 0;
  108. document.documentElement.scrollTop = 0;
  109. },
  110. handleScroll() {
  111. this.showBackToTop = (document.body.scrollTop || document.documentElement.scrollTop) >= 0.5 * document.body.clientHeight;
  112. }
  113. },
  114. mounted() {
  115. this.throttledScrollHandler = throttle(300, this.handleScroll);
  116. document.addEventListener('scroll', this.throttledScrollHandler);
  117. },
  118. beforeDestroy() {
  119. document.removeEventListener('scroll', this.throttledScrollHandler);
  120. }
  121. };
  122. </script>