carousels.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="swiper-content">
  3. <swiper class="swiper-box" autoplay :interval="3000" circular @change="change">
  4. <swiper-item v-for="(item ,index) in BannerList" :key="index">
  5. <view class="swiper-item">
  6. <image :src="item.thumbnail" mode="aspectFit"></image>
  7. </view>
  8. </swiper-item>
  9. </swiper>
  10. <div class="custom-indicator">
  11. <span :class="['indicator' , current === index ? 'active-indicator' : '']"
  12. v-for="(item , index) in BannerList">
  13. </span>
  14. </div>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: "carousels",
  20. props: {
  21. BannerList: {
  22. type: Array,
  23. default: () => []
  24. }
  25. },
  26. data() {
  27. return {
  28. info: [{
  29. content: '内容 A'
  30. }, {
  31. content: '内容 B'
  32. }, {
  33. content: '内容 C'
  34. }],
  35. current: 0,
  36. mode: 'round',
  37. }
  38. },
  39. methods: {
  40. change(e) {
  41. this.current = e.detail.current;
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .swiper-content {
  48. background-color: $modules-box-bg;
  49. padding: 0 $pages-padding;
  50. }
  51. .swiper-box {
  52. .swiper-item {
  53. width: 100%;
  54. height: 280rpx;
  55. image {
  56. width: 100%;
  57. height: 100%;
  58. }
  59. }
  60. }
  61. .custom-indicator {
  62. width: 100%;
  63. padding-top: 15rpx;
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. flex-wrap: wrap;
  68. // gap: 20rpx 20rpx;
  69. .indicator {
  70. width: 10rpx;
  71. height: 10rpx;
  72. background-color: #d9d9d9;
  73. transform: rotate(45deg);
  74. }
  75. .indicator+.indicator {
  76. margin-left: 20rpx;
  77. }
  78. .active-indicator {
  79. background-color: #27B082;
  80. }
  81. }
  82. // .my-swipe {
  83. // overflow: hidden;
  84. // ::v-deep .van-swipe__track {
  85. // height: 280rpx;
  86. // }
  87. // .van-swipe-item {
  88. // display: inline-block;
  89. // height: 100%;
  90. // .swipe-img {
  91. // width: 100%;
  92. // height: 100%;
  93. // ::v-deep .van-image__img {
  94. // width: 100%;
  95. // height: 100%;
  96. // }
  97. // }
  98. // ;
  99. // }
  100. // }
  101. // .custom-indicator {
  102. // width: 100%;
  103. // padding-top: 15rpx;
  104. // display: flex;
  105. // justify-content: center;
  106. // align-items: center;
  107. // flex-wrap: wrap;
  108. // gap: 20rpx 20rpx;
  109. // .indicator {
  110. // width: 10rpx;
  111. // height: 10rpx;
  112. // background-color: #d9d9d9;
  113. // transform: rotate(45deg);
  114. // }
  115. // .active-indicator {
  116. // background-color: #27B082;
  117. // }
  118. // }
  119. </style>