自定义轮播图

 

 <view class="swiper-container">
            <swiper autoplay="{{true}}" interval="4000" duration="500" previous-margin="30px" next-margin="15px" current="{{swiperCurrent}}" bindchange="swiperChange" class="swiper" circular="{{true}}">
              <block wx:for="{{imgUrls}}" wx:key="unique">
                <swiper-item>
                  <image src="{{item}}" class="img"></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>
/* 轮播图 */

swiper-container {
    position: relative;
    
   
}

.swiper-container .swiper {
    height: 350rpx;
     background: #fff;
 
}

.swiper-container .swiper .img {
    width: 96%;
    height: 300rpx;
    border-radius: 20rpx;
     box-shadow:5px 5px 20px #C9C9C9;
}

.swiper-container .dots {
    padding-top: 20rpx;
    display: flex;
    justify-content: center;
    background:none;
}

.swiper-container .dots .dot {
    margin: -40rpx 8rpx;
    width: 20rpx;
    height: 15rpx;
    background: #ccc;
    border-radius: 15rpx;
    transition: all 0.6s;
}

.swiper-container .dots .dot.active {
    width: 30rpx;
    /* background: #f80; */
    background: linear-gradient(to bottom right, #f6743b , #f33a3e);
}
data:{
   
  // 轮播
    swiperCurrent: 0,
    imgUrls: [
      '../../img/Famous/1.jpg',
      '../../img/Famous/2.jpg',
      '../../img/Famous/3.jpg'
    ],
}
  // 轮播
  swiperChange: function(e) {
    this.setData({
      swiperCurrent: e.detail.current
    })
  },

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值