momozjm

小程序之修改轮播图的小点样式

1、单独写一个小点的元素。

<view class=\'swiper-box\'>
    <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" bindchange="swiperChange">
      <block wx:for="{{imgUrls}}">
        <swiper-item>
          <image src="{{item}}" class="slide-image" />
        </swiper-item>
      </block>
    </swiper>
    <view class="dots">  
      <block wx:for="{{imgUrls}}" wx:key="unique">  
        <view class="dot{{index == swiperCurrent ? \' active\' : \'\'}}"></view>  
      </block>  
    </view>
  </view>

  

2、将轮播图组件自带的小点隐藏

indicatorDots: false

  

3、修改样式

swiper{
  width: 100%;
}

.swiper-box{
  position: relative;
  width: 100%;
}
.dots{  
  position: absolute;  
  left: 0;  
  right: 0;  
  bottom: 20rpx;  
  display: flex;  
  justify-content: center;  
}  
.dots .dot{  
  margin: 0 8rpx;  
  width: 14rpx;  
  height: 14rpx;  
  background: #fff;  
  border-radius: 8rpx;  
  transition: all .6s;  
}  
.dots .dot.active{  
  width: 24rpx;  
  background: #f80;  
} 

swiper image {
  width: 100%;
  height: 100%;
}

  

分类:

技术点:

相关文章:

  • 2021-06-30
  • 2022-02-28
  • 2022-12-23
  • 2021-10-06
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-10-06
相关资源
相似解决方案