show.vue 4.4 KB

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