开放平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

193 wiersze
4.5 KiB

  1. <template>
  2. <div class="components-add">
  3. <div class="add-api-box">
  4. <div class="add-head">
  5. <span>添加API</span>
  6. <i class="el-icon-close" @click="onClose"></i>
  7. </div>
  8. <div class="tab-content">
  9. <div class="tab-box" ref="tabItem">
  10. <div @click="changeTab(0, $event)">全部</div>
  11. <div @click="changeTab(1, $event)">基础工具API</div>
  12. <div @click="changeTab(2, $event)">搜索相关API</div>
  13. <div @click="changeTab(3, $event)">特色栏目API</div>
  14. <div @click="changeTab(4, $event)">入库更新API</div>
  15. <div ref="tabLine" class="tab-line"></div>
  16. </div>
  17. <div class="content-box">
  18. <div
  19. class="content-item"
  20. v-for="(item, index) in 20"
  21. :key="index"
  22. >
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. setWidth: 0,
  34. };
  35. },
  36. created() {
  37. document.body.style.overflow = "hidden";
  38. },
  39. destroyed() {
  40. document.body.style.overflow = "auto";
  41. },
  42. mounted() {
  43. this.setWidth = this.$refs.tabItem.children[0].offsetWidth;
  44. this.$refs.tabLine.style.width = this.setWidth + "px";
  45. this.$refs.tabLine.style.transform = `translateX(${this.offSet}px)`;
  46. this.$refs.tabLine.style.transition = "transform .5s ,width .5s ";
  47. },
  48. methods: {
  49. changeTab: function (value, e) {
  50. let offSet = 0;
  51. for (let i = 0; i < value; i++) {
  52. offSet = offSet + this.$refs.tabItem.children[i].offsetWidth + 50;
  53. }
  54. let width = e.target.offsetWidth; // 当前元素的宽
  55. this.$refs.tabLine.style.transform = `translateX(${offSet}px)`;
  56. this.$refs.tabLine.style.width = width + "px";
  57. this.$refs.tabLine.style.transition = "transform .5s , width .5s ";
  58. },
  59. onClose(){
  60. this.$emit('onClose')
  61. }
  62. },
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .components-add {
  67. position: fixed;
  68. top: 0;
  69. left: 0;
  70. right: 0;
  71. bottom: 0;
  72. width: 100vw;
  73. min-height: 100vh;
  74. overflow-x: hidden;
  75. background: rgba($color: #000000, $alpha: 0.3);
  76. z-index: 99;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. .add-api-box {
  81. width: 1080px;
  82. height: 690px;
  83. background: #ffffff;
  84. border-radius: 14px;
  85. box-sizing: border-box;
  86. overflow: hidden;
  87. .add-head {
  88. width: 100%;
  89. height: 64px;
  90. background: #fafafa;
  91. padding: 0 20px;
  92. box-sizing: border-box;
  93. display: flex;
  94. flex-flow: row nowrap;
  95. justify-content: space-between;
  96. align-items: center;
  97. span {
  98. padding-left: 15px;
  99. border-left: 4px solid #1890ff;
  100. display: inline-block;
  101. line-height: 19px;
  102. height: 19px;
  103. font-size: 19px;
  104. }
  105. .el-icon-close {
  106. font-size: 16px;
  107. width: 30px;
  108. cursor: pointer;
  109. text-align: center;
  110. height: 30px;
  111. line-height: 30px;
  112. }
  113. }
  114. .tab-content {
  115. height: 546px;
  116. width: 100%;
  117. overflow-y: auto;
  118. padding-bottom: 20px;
  119. box-sizing: border-box;
  120. border-bottom: 1px solid #eeeeee;
  121. .tab-box {
  122. height: 96px;
  123. background: #fff;
  124. padding: 0 20px;
  125. box-sizing: border-box;
  126. display: flex;
  127. position: relative;
  128. align-items: center;
  129. div {
  130. margin-right: 50px;
  131. color: #333333;
  132. font-size: 20px;
  133. position: relative;
  134. cursor: pointer;
  135. }
  136. .tab-line {
  137. position: absolute;
  138. width: 0;
  139. height: 4px;
  140. bottom: 25px;
  141. left: 21px;
  142. background-color: #1890ff;
  143. transform: translateX(0);
  144. }
  145. }
  146. .content-box {
  147. display: flex;
  148. flex-flow: wrap;
  149. width: 100%;
  150. padding: 0 20px 0 20px;
  151. box-sizing: border-box;
  152. justify-content: space-between; /* 横向中间自动空间 */
  153. .content-item {
  154. width: 330px;
  155. height: 130px;
  156. background: #ffffff;
  157. border-radius: 14px;
  158. border: 1px solid #dddddd;
  159. margin-bottom: 20px;
  160. }
  161. }
  162. }
  163. .tab-content::-webkit-scrollbar {
  164. // width: 6px;
  165. // height: 60px;
  166. // background: #d8d8d8;
  167. // border-radius: 3px;
  168. background: #fff;
  169. width: 6px;
  170. }
  171. .tab-content::-webkit-scrollbar-thumb {
  172. width: 6px;
  173. height: 60px;
  174. background: #d8d8d8;
  175. border-radius: 3px;
  176. }
  177. }
  178. }
  179. </style>