经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » JS/JS库/框架 » Vue.js » 查看文章
Vue实现时间轴功能
来源:jb51  时间:2022/2/28 8:51:13  对本文有异议

本文实例为大家分享了Vue实现时间轴功能的具体代码,供大家参考,具体内容如下

  1. <template>
  2. ? <div class="container">
  3. ? ? <div class="content">
  4. ? ? ? <div class="coin" v-for="(item,index1) in Math.ceil((list.length+1)/4)" :key="index1" v-show="isShow==index1">
  5. ? ? ? ? <div class="xs_one"></div>
  6. ? ? ? ? <div
  7. ? ? ? ? ? class="coinAll"
  8. ? ? ? ? ? v-for="(item, index) in list"
  9. ? ? ? ? ? :key="index"
  10. ? ? ? ? ? :class="{ one: index%4==0 }"
  11. ? ? ? ? ? v-show="index<(index1+1)*4 && index+1>(index1)*4"
  12. ? ? ? ? >
  13. ? ? ? ? ? <span
  14. ? ? ? ? ? ? :class="{
  15. ? ? ? ? ? ? ? two: (index + 1) % 2 == 0,
  16. ? ? ? ? ? ? ? text_active: index == isIndex,
  17. ? ? ? ? ? ? }"
  18. ? ? ? ? ? >
  19. ? ? ? ? ? ? {{ item }}
  20. ? ? ? ? ? </span>
  21. ? ? ? ? ? <div class="xs" :class="{ xs_active: index == isIndex }"></div>
  22. ? ? ? ? ? <img src="../assets/img/coin1.png" alt="" v-show="index == isIndex" />
  23. ? ? ? ? ? <img src="../assets/img/coin2.png" alt="" v-show="index != isIndex" />
  24. ? ? ? ? </div>
  25. ? ? ? </div>
  26. ? ? ? <div class="paging" :style="{width:Math.ceil((list.length+1)/4)*20+'px'}">
  27. ? ? ? ? <div class="pagings" v-for="(item,index1) in Math.ceil((list.length+1)/4)" :key="index1" @click="tabList(index1)" :class="{is_activ:isShow==index1}">{{index}}</div>
  28. ? ? ? </div>
  29. ? ? </div>
  30. ? </div>
  31. </template>
  32. ?
  33. ?
  34. <script>
  35. export default {
  36. ? data() {
  37. ? ? return {
  38. ? ? ? list: ["实施方案", "任务书", "中期检查", "项目验收", "分页功能1","分页功能1","分页功能1","分页功能1","分页功能2"], //列表
  39. ? ? ? isIndex: 0, //高亮显示
  40. ? ? ? isShow: 1, //显示
  41. ? ? };
  42. ? },
  43. ? methods:{
  44. ? ? tabList(idx){
  45. ? ? ? this.isShow=idx
  46. ? ? }
  47. ? }
  48. };
  49. </script>
  50. ?
  51. ?
  52. <style scoped>
  53. .content {
  54. ? width: 400px;
  55. ? height: 120px;
  56. ? background: rgb(9, 27, 70);
  57. ? position: relative;
  58. }
  59. .paging{
  60. ? height: 20px;
  61. ? position: absolute;
  62. ? bottom: 10px;
  63. ? left: 50%;
  64. ? transform: translate(-50%);
  65. }
  66. .paging div{
  67. ? width: 15px;
  68. ? height: 15px;
  69. ? border-radius: 50%;
  70. ? background: rgb(120, 120, 120);
  71. ? float: left;
  72. ? margin-left: 5px;
  73. }
  74. .coin {
  75. ? width: 100%;
  76. ? height: 80px;
  77. ? background: rgb(9, 27, 70);
  78. ? position: relative;
  79. ? overflow-x: hidden;
  80. }
  81. .xs_one {
  82. ? width: 100%;
  83. ? height: 5px;
  84. ? background: rgb(61, 183, 270);
  85. ? position: absolute;
  86. ? top: 50%;
  87. ? left: 0;
  88. ? transform: translate(0, -50%);
  89. }
  90. .coin .coinAll {
  91. ? width: 100px;
  92. ? height: 100%;
  93. ? float: left;
  94. ? position: relative;
  95. }
  96. ?
  97. .coin .one {
  98. ? margin-left: -50px;
  99. }
  100. .coin .coinAll img {
  101. ? position: absolute;
  102. ? top: 50%;
  103. ? right: 0;
  104. ? transform: translate(0, -50%);
  105. }
  106. .coin .coinAll .xs {
  107. ? width: 100%;
  108. ? height: 5px;
  109. ? background: rgb(61, 183, 270);
  110. ? position: absolute;
  111. ? top: 50%;
  112. ? left: 0;
  113. ? transform: translate(0, -50%);
  114. }
  115. ?
  116. .coin .coinAll span {
  117. ? width: 100%;
  118. ? color: #fff;
  119. ? font-size: 16px;
  120. ? position: absolute;
  121. ? top: 5px;
  122. }
  123. .coin .coinAll .two {
  124. ? width: 100%;
  125. ? color: #fff;
  126. ? font-size: 16px;
  127. ? position: absolute;
  128. ? top: 55px;
  129. }
  130. ?
  131. /* 文字高亮 */
  132. .coin .coinAll .text_active {
  133. ? color: rgb(245, 189, 39);
  134. }
  135. ?
  136. /* 线条高亮 */
  137. .coin .coinAll .xs_active {
  138. ? background: rgb(245, 189, 39);
  139. }
  140. .paging .is_activ{
  141. ? background: rgb(26, 82, 229);
  142. }
  143. </style>

效果如图

新增分页

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号