index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. @include useTheme() {
  38. display: flex;
  39. justify-content: space-evenly;
  40. align-items: center;
  41. padding: 24px 0;
  42. .simple-step__item {
  43. font-size: 24px;
  44. color: #282828;
  45. position: relative;
  46. padding-bottom: 4px;
  47. &.active {
  48. .simple-step__line {
  49. position: absolute;
  50. bottom: 0;
  51. left: 0;
  52. width: 100%;
  53. height: 3px;
  54. background-color: fetch('color');
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. // 移动端
  62. @media screen and (max-width: 768px) {
  63. .simple-step {
  64. @include useTheme() {
  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. &.active {
  75. color: #282828;
  76. .simple-step__line {
  77. position: absolute;
  78. bottom: 0;
  79. left: 0;
  80. width: 100%;
  81. height: 0.5vw;
  82. background-color: fetch('color');
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. </style>