component.tpl 3.0 KB

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