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

 

本功能参考自https://www.cnblogs.com/momozjm/p/8609728.html  在原来的代码上添加部分js

效果如下:

                                                          小程序修改轮播图的小点样式_第1张图片

wxml: 


    
      
        
          
        
      
    
     
       
         
       
    
  

css: 

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: orchid; 
}
 
swiper image {
  width: 100%;
  height: 100%;
}

js

data:{
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    indicatorDots: false,
    autoplay: true,
    interval: 4000,
    duration: 800,
    swiperCurrent: 0,

}
  swiperChange(e) {
    let current = e.detail.current;
    // console.log(current, '轮播图')
    let that = this;
    that.setData({
      swiperCurrent: current,
    })
  },

 

你可能感兴趣的:(微信小程序,小程序)