carousels.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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="`swiper_${index}`">
  5. <view class="swiper-item" @click.stop="lookDetails(item)">
  6. <image :src="item.thumbnail" ></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. lookDetails(item){
  44. // uni.navigateTo({
  45. // url: this.$path.articleDetails + `${item.id}`
  46. // })
  47. uni.navigateTo({
  48. url:`/pages/content/affiche?link=${item.link}`
  49. })
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .swiper-box{
  56. height: 280rpx;
  57. }
  58. .swiper-content {
  59. padding: 0 $pages-padding;
  60. }
  61. .swiper-box {
  62. .swiper-item {
  63. width: 100%;
  64. height: 280rpx;
  65. image {
  66. width: 100%;
  67. height: 100%;
  68. border-radius: 10rpx;
  69. }
  70. }
  71. }
  72. .custom-indicator {
  73. width: 100%;
  74. padding-top: 20rpx;
  75. display: flex;
  76. justify-content: center;
  77. align-items: center;
  78. flex-wrap: wrap;
  79. // gap: 20rpx 20rpx;
  80. .indicator {
  81. width: 8rpx;
  82. height: 8rpx;
  83. background-color: #d9d9d9;
  84. transform: rotate(45deg);
  85. }
  86. .indicator+.indicator {
  87. margin-left: 16rpx;
  88. }
  89. .active-indicator {
  90. background-color: #27B082;
  91. }
  92. }
  93. // .my-swipe {
  94. // overflow: hidden;
  95. // ::v-deep .van-swipe__track {
  96. // height: 280rpx;
  97. // }
  98. // .van-swipe-item {
  99. // display: inline-block;
  100. // height: 100%;
  101. // .swipe-img {
  102. // width: 100%;
  103. // height: 100%;
  104. // ::v-deep .van-image__img {
  105. // width: 100%;
  106. // height: 100%;
  107. // }
  108. // }
  109. // ;
  110. // }
  111. // }
  112. // .custom-indicator {
  113. // width: 100%;
  114. // padding-top: 15rpx;
  115. // display: flex;
  116. // justify-content: center;
  117. // align-items: center;
  118. // flex-wrap: wrap;
  119. // gap: 20rpx 20rpx;
  120. // .indicator {
  121. // width: 10rpx;
  122. // height: 10rpx;
  123. // background-color: #d9d9d9;
  124. // transform: rotate(45deg);
  125. // }
  126. // .active-indicator {
  127. // background-color: #27B082;
  128. // }
  129. // }
  130. </style>