index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="simple-step">
  3. <div
  4. class="simple-step__item"
  5. v-for="(item, index) in list"
  6. :key="index"
  7. :class="{ active: item.id === active }"
  8. >
  9. <span v-text="item[label]"></span>
  10. <span class="simple-step__line"></span>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'simple-step',
  17. props: {
  18. list: {
  19. type: Array,
  20. default: [],
  21. },
  22. label: {
  23. type: String,
  24. default: 'label',
  25. },
  26. active: {
  27. type: Number,
  28. default: 0,
  29. },
  30. },
  31. }
  32. </script>
  33. <style lang="scss" scoped>
  34. // pc端
  35. @media screen and (min-width: 768px) {
  36. .simple-step {
  37. display: flex;
  38. justify-content: space-evenly;
  39. align-items: center;
  40. padding: 24px 0;
  41. .simple-step__item {
  42. font-size: 24px;
  43. color: #282828;
  44. position: relative;
  45. padding-bottom: 4px;
  46. cursor: pointer;
  47. &.active {
  48. .simple-step__line {
  49. position: absolute;
  50. bottom: 0;
  51. left: 0;
  52. width: 100%;
  53. height: 3px;
  54. @include themify($themes) {
  55. background-color: themed('color');
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. // 移动端
  63. @media screen and (max-width: 768px) {
  64. .simple-step {
  65. display: flex;
  66. justify-content: space-evenly;
  67. align-items: center;
  68. padding: 8vw 0 6vw;
  69. .simple-step__item {
  70. font-size: 4.2vw;
  71. color: #999;
  72. position: relative;
  73. padding-bottom: 1.2vw;
  74. cursor: pointer;
  75. &.active {
  76. color: #282828;
  77. .simple-step__line {
  78. position: absolute;
  79. bottom: 0;
  80. left: 0;
  81. width: 100%;
  82. height: 0.5vw;
  83. @include themify($themes) {
  84. background-color: themed('color');
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. </style>