上面卡片正常滑动,点击下面的小卡牌,切换到当前的对应的卡片。

    原生 js 版

    1. <section>
    2. <div class="swiper-container">
    3. <div class="swiper-wrapper">
    4. <div class="swiper-slide">女皇
    5. <p class="card-btn">送给朋友一张</p>
    6. </div>
    7. <div class="swiper-slide">世界
    8. <p class="card-btn">送给朋友一张</p>
    9. </div>
    10. <div class="swiper-slide">星星
    11. <p class="card-btn">送给朋友一张</p>
    12. </div>
    13. <div class="swiper-slide">月亮
    14. <p class="card-btn">送给朋友一张</p>
    15. </div>
    16. <div class="swiper-slide">魔术师
    17. <p class="card-btn">送给朋友一张</p>
    18. </div>
    19. <div class="swiper-slide">太阳
    20. <p class="card-btn">送给朋友一张</p>
    21. </div>
    22. </div>
    23. </div>
    24. <div class="contrast-box">
    25. <ul>
    26. <li data-index="5">魔术师</li>
    27. <li data-index="6">太阳</li>
    28. <li data-index="1">女皇</li>
    29. <li data-index="2">世界</li>
    30. <li data-index="3">星星</li>
    31. <li data-index="4">月亮</li>
    32. <li class="combin-btn">合成</li>
    33. </ul>
    34. </div>
    35. <div class="button-next"></div>
    36. <div class="button-prev"></div>
    37. </section>
    38. var mySwiper = new Swiper('.swiper-container', {
    39. nextButton: '.button-next',
    40. prevButton: '.button-prev',
    41. effect: 'coverflow', //3d滑动
    42. grabCursor: true,
    43. centeredSlides: true, // 居中
    44. slidesPerView: 'auto',
    45. loop: true,
    46. slidesPerView: 2, // 显示2个
    47. coverflow: {
    48. rotate: 0, //设置为0
    49. stretch: 0,
    50. depth: 200,
    51. modifier: 2,
    52. slideShadows: true
    53. }
    54. })
    55. $('.contrast-box').on('click', ()=> {
    56. var _index = $(this).data('index') + 1
    57. mySwiper.slideTo(_index, 500, false)//切换到第一个slide,速度为1秒
    58. })
    59. $('.button-prev').click(()=> mySwiper.slidePrev())
    60. $('.button-next').click(()=> mySwiper.slideNext())

    IMG_CF17BB30E65A-1.jpeg