swiper.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div class="swiper-page">
  3. <div v-swiper:mySwiper="swiperOption" class="swiper-container">
  4. <div class="swiper-wrapper">
  5. <div class="swiper-slide" v-for="(item, idx) in swiperData" :key="idx">
  6. <img :src="item.imgUrl" />
  7. </div>
  8. </div>
  9. <div class="swiper-pagination swiper-pagination-style"></div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import Swiper, {Navigation, Pagination,Autoplay} from 'swiper';
  15. Swiper.use([Navigation, Pagination,Autoplay]);
  16. export default {
  17. data() {
  18. return {
  19. swiperData: [
  20. { imgUrl: require(`~/static/images/client/index/index-products-kaoshi.png`)},
  21. { imgUrl: require(`~/static/images/client/index/index-products-peixun.png`) },
  22. { imgUrl: require(`~/static/images/client/index/index-products-kejian.png`) },
  23. ],
  24. swiperOption: {
  25. pagination: {
  26. el: '.swiper-pagination',
  27. bulletClass: 'my-bullet-swiper', // 自定义设置默认类名
  28. bulletActiveClass: 'my-bullet-active-swiper', // 自定义滑块活跃类名
  29. clickable: true, // 点击当前滑块切换到对应的轮播图片
  30. },
  31. autoplay: {
  32. delay: 2000,
  33. },
  34. paginationClickable: true,
  35. speed: 800,
  36. loop: true,
  37. observer: true,
  38. observeParents: true,
  39. autoplayDisableOnInteraction: false,
  40. },
  41. }
  42. },
  43. }
  44. </script>
  45. <style lang="scss">
  46. .swiper-page {
  47. position: relative;
  48. .swiper-slide {
  49. width: 760px;
  50. height: 440px;
  51. // box-shadow: 0 0 30px 3px rgba(77, 97, 140, 0.4);
  52. img {
  53. width: 760px;
  54. height: 440px;
  55. }
  56. }
  57. .swiper-pagination-style {
  58. position: absolute;
  59. left: 60px;
  60. bottom: 39px;
  61. width: 300px;
  62. .my-bullet-swiper {
  63. display: inline-block;
  64. width: 46px;
  65. height: 6px;
  66. background: #9b9bb6;
  67. margin-right: 14px;
  68. }
  69. .my-bullet-active-swiper {
  70. background: #ffd18e;
  71. }
  72. }
  73. }
  74. </style>
  75. <!--
  76. <SwiperCmp :list="banners" :isPagination="true" :className="'swiperClass'" :paginationType="bullets"/>
  77. import SwiperCmp from '../components/swiper.vue'
  78. components:{SwiperCmp},
  79. -->