component.tpl 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. ul {
  38. margin: 10px 0;
  39. padding: 0 0 0 20px;
  40. font-size: 14px;
  41. color: #5e6d82;
  42. line-height: 2em;
  43. }
  44. }
  45. }
  46. .page-component-up {
  47. background-color: #58b7ff;
  48. position: fixed;
  49. right: 100px;
  50. bottom: 150px;
  51. size: 50px;
  52. border-radius: 25px;
  53. cursor: pointer;
  54. opacity: 0.4;
  55. transition: .3s;
  56. i {
  57. color: #fff;
  58. display: block;
  59. line-height: 50px;
  60. text-align: center;
  61. font-size: 22px;
  62. }
  63. &.hover {
  64. opacity: 1;
  65. }
  66. }
  67. .back-top-fade-enter,
  68. .back-top-fade-leave-active {
  69. transform: translateY(-30px);
  70. opacity: 0;
  71. }
  72. }
  73. </style>
  74. <template>
  75. <div class="page-container page-component">
  76. <el-row>
  77. <el-col :xs="24" :sm="6">
  78. <side-nav :data="navsData[lang]" :base="`/${ lang }/component`"></side-nav>
  79. </el-col>
  80. <el-col :xs="24" :sm="18">
  81. <router-view class="content"></router-view>
  82. <footer-nav></footer-nav>
  83. </el-col>
  84. </el-row>
  85. <transition name="back-top-fade">
  86. <div
  87. class="page-component-up"
  88. :class="{ 'hover': hover }"
  89. v-show="showBackToTop"
  90. @mouseenter="hover = true"
  91. @mouseleave="hover = false"
  92. @click="toTop">
  93. <i class="el-icon-caret-top"></i>
  94. </div>
  95. </transition>
  96. </div>
  97. </template>
  98. <script>
  99. import navsData from '../../nav.config.json';
  100. import throttle from 'throttle-debounce/throttle';
  101. export default {
  102. data() {
  103. return {
  104. lang: this.$route.meta.lang,
  105. navsData,
  106. hover: false,
  107. showBackToTop: false
  108. };
  109. },
  110. methods: {
  111. toTop() {
  112. this.hover = false;
  113. this.showBackToTop = false;
  114. document.body.scrollTop = 0;
  115. document.documentElement.scrollTop = 0;
  116. },
  117. handleScroll() {
  118. this.showBackToTop = (document.body.scrollTop || document.documentElement.scrollTop) >= 0.5 * document.body.clientHeight;
  119. }
  120. },
  121. mounted() {
  122. this.throttledScrollHandler = throttle(300, this.handleScroll);
  123. document.addEventListener('scroll', this.throttledScrollHandler);
  124. },
  125. beforeDestroy() {
  126. document.removeEventListener('scroll', this.throttledScrollHandler);
  127. }
  128. };
  129. </script>