ProductTabs.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <section class="mb-tabs-container">
  3. <section class="mb-tabs">
  4. <div v-for="(tab, index) in productTabs" :key="index" class="tab-item" :class="{ active: activeTab === index }"
  5. @click="activeTab = index">
  6. {{ tab.name }}
  7. </div>
  8. <!-- <van-tabs v-model:active="activeTab">
  9. <van-tab v-for="(tab, index) in productTabs" :title="tab.name">
  10. </van-tab>
  11. </van-tabs> -->
  12. </section>
  13. </section>
  14. </template>
  15. <script setup>
  16. import { productTabs } from '~/utils/product';
  17. const activeTab = ref(0)
  18. const currentTabData = computed(() => productTabs[activeTab.value])
  19. </script>
  20. <style lang="scss" scoped>
  21. .mb-tabs-container {
  22. position: absolute;
  23. width: 100%;
  24. left: 0;
  25. top: 58%;
  26. transform: translateY(-50%);
  27. z-index: 2;
  28. }
  29. .mb-tabs {
  30. width: 100%;
  31. box-sizing: border-box;
  32. height: 42px;
  33. margin: 0 auto;
  34. border-radius: 150px;
  35. background: linear-gradient(177deg, rgba(165, 101, 255, 0.30) -20.47%, rgba(3, 0, 20, 0.30) 134.25%);
  36. backdrop-filter: blur(20px);
  37. display: flex;
  38. align-items: center;
  39. gap: 8px;
  40. padding: 0 12px;
  41. overflow-x: auto;
  42. scroll-behavior: smooth;
  43. -webkit-overflow-scrolling: touch;
  44. /* 隐藏滚动条 */
  45. scrollbar-width: none;
  46. -ms-overflow-style: none;
  47. &::-webkit-scrollbar {
  48. display: none;
  49. }
  50. .tab-item {
  51. flex-shrink: 0;
  52. font-size: 14px;
  53. font-weight: 400;
  54. line-height: 1;
  55. color: #ffffff;
  56. cursor: pointer;
  57. white-space: nowrap;
  58. transition: color 0.3s ease, background 0.3s ease, transform 0.3s ease;
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. min-width: 88px;
  63. height: 32px;
  64. padding: 0 16px;
  65. border-radius: 16px;
  66. background: transparent;
  67. &.active {
  68. background: linear-gradient(62.84deg, rgba(130, 77, 255, 1) 0%, rgba(164, 125, 255, 1) 100%);
  69. color: #ffffff;
  70. font-weight: 500;
  71. }
  72. &:hover:not(.active) {
  73. color: #bdbdbd;
  74. transform: translateY(-1px);
  75. }
  76. }
  77. }
  78. </style>