show.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { Swiper, SwiperSlide } from 'swiper/vue'
  4. import { Autoplay, EffectCards, Navigation, Pagination } from 'swiper/modules'
  5. import 'swiper/css'
  6. import 'swiper/css/navigation'
  7. import 'swiper/css/autoplay'
  8. import 'swiper/css/pagination'
  9. import 'swiper/css/effect-cards'
  10. // import 'swiper/css/bundle' // 全部css
  11. const modules = [Navigation, Pagination, EffectCards, Autoplay]
  12. const swiperVertical = ref<any>(null)
  13. const swiperHorizontal = ref<any>(null)
  14. function onVerticalSwiper(swiper: any) {
  15. swiperVertical.value = swiper
  16. }
  17. function onHorizontalSwiper(swiper: any) {
  18. swiperHorizontal.value = swiper
  19. }
  20. function onSlideChange(swiper: any) {
  21. if (!swiperVertical.value)
  22. return
  23. swiperVertical.value.slideTo(swiper.realIndex)
  24. }
  25. function onSlideChange2(swiper: any) {
  26. if (!swiperHorizontal.value)
  27. return
  28. swiperHorizontal.value.slideTo(swiper.realIndex)
  29. }
  30. const list = ref([
  31. {
  32. title: 'Insight-Driven Creativity111',
  33. description:
  34. 'We believe creativity should be rooted in real consumer insights. Every idea starts with what the new generation truly wants — we turn those insights into inspiring products.',
  35. },
  36. {
  37. title: 'Insight-Driven Creativity22',
  38. description:
  39. 'We believe creativity should be rooted in real consumer insights. Every idea starts with what the new generation truly wants — we turn those insights into inspiring products.',
  40. },
  41. {
  42. title: 'Insight-Driven Creativity333',
  43. description:
  44. 'We believe creativity should be rooted in real consumer insights. Every idea starts with what the new generation truly wants — we turn those insights into inspiring products.',
  45. },
  46. ])
  47. onUnmounted(() => {
  48. if (swiperVertical.value) {
  49. swiperVertical.value.destroy()
  50. swiperVertical.value = null
  51. }
  52. })
  53. </script>
  54. <template>
  55. <div class="bg-#EAE5FA">
  56. <div class="w-1200-auto">
  57. <div class="flex justify-between ">
  58. <div class="w-50% block-left flex user-select justify-center items-center pr-100px">
  59. <Swiper
  60. :modules="modules"
  61. mousewheel="false"
  62. :loop="true"
  63. effect="cards"
  64. grab-cursor="true"
  65. :autoplay="{
  66. delay: 3000,
  67. disableOnInteraction: false,
  68. pauseOnMouseEnter: true,
  69. }"
  70. :pagination="{
  71. clickable: true,
  72. }"
  73. class="pos-relative"
  74. @slide-change="onSlideChange2"
  75. @swiper="onVerticalSwiper"
  76. >
  77. <SwiperSlide v-for="(item, index) in list" :key="index">
  78. Slide {{ index }}
  79. </SwiperSlide>
  80. </Swiper>
  81. </div>
  82. <div class="w-50% h-700px pos-relative block-right">
  83. <Swiper
  84. direction="vertical"
  85. :modules="modules"
  86. mousewheel="false"
  87. :loop="true"
  88. :allow-touch-move="false"
  89. :pagination="false"
  90. class="pos-relative"
  91. @swiper="onHorizontalSwiper"
  92. >
  93. <SwiperSlide v-for="(item, index) in list" :key="index">
  94. <div class="text-left user-select">
  95. <div class="text-40px fw-800 text-#333 custom-title-font">
  96. {{ item.title }}
  97. </div>
  98. <div class="text-#999 mt-20px lh-24px">
  99. {{ item.description }}
  100. </div>
  101. </div>
  102. </SwiperSlide>
  103. </Swiper>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. <style lang="less" scoped>
  110. .user-select{
  111. user-select: none;
  112. }
  113. :deep(.block-right) {
  114. .swiper {
  115. position: relative;
  116. width: 100%;
  117. height: 100%;
  118. .swiper-slide {
  119. text-align: center;
  120. font-size: 18px;
  121. display: flex;
  122. justify-content: center;
  123. align-items: center;
  124. }
  125. }
  126. }
  127. :deep(.block-left) {
  128. .swiper {
  129. width: 480px;
  130. height: 480px;
  131. }
  132. .swiper-slide {
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. border-radius: 18px;
  137. font-size: 22px;
  138. font-weight: bold;
  139. color: #fff;
  140. }
  141. .swiper-pagination{
  142. top: unset;
  143. bottom: -80px;
  144. left: unset;
  145. right: -100px;
  146. display: flex;
  147. justify-content: end;
  148. }
  149. .swiper-slide:nth-child(1n) {
  150. background-color: rgb(206, 17, 17);
  151. }
  152. .swiper-slide:nth-child(2n) {
  153. background-color: rgb(0, 140, 255);
  154. }
  155. .swiper-slide:nth-child(3n) {
  156. background-color: rgb(10, 184, 111);
  157. }
  158. }
  159. </style>