carousels.vue 2.3 KB

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