小程序轮播

wxml:

<!-- 轮播 -->

<view class="swiper-container">

<swiper autoplay="auto" interval="5000" duration="500" current="{{swiperCurrent}}" bindanimationfinish="swiperChange" class="swiper">

<block wx:for="{{slider}}" wx:key="unique">

<swiper-item>

<image src="{{item.picUrl}}" class="img"></image>

</swiper-item>

</block>

</swiper>

<view class="dots">

<block wx:for="{{slider}}" wx:key="unique">

<view class="dot{{index == swiperCurrent ? ' active' : ''}}"></view>

</block>

</view>

</view>

wxss:

/* 轮播图 */

.swiper-container{

position: relative;

}

/* 轮播图效果 */

.swiper-container,.swiper,.swiper-item{

box-shadow:0px 0px 18rpx 0rpx rgba(103,112,134,0.15);

border-radius:15rpx;

}

.swiper-container .swiper{

height: 300rpx;

}

.banner-img{

border-radius:15rpx;

}

.swiper-container .swiper .img{

width: 100%;

height: 100%;

}

.swiper-container .dots{

position: absolute;

left: 0;

right: 0;

bottom: 20rpx;

display: flex;

justify-content: center;

}

.swiper-container .dots .dot{

margin: 0 8rpx;

width: 14rpx;

height: 14rpx;

background: #fff;

border-radius: 8rpx;

transition: all .6s;

}

.swiper-container .dots .dot.active{

width: 24rpx;

background: rgba(119,156,217,1);

}

.category-of-works{

width:124rpx;

height:42rpx;

line-height: 42rpx;

text-align: center;

background:rgba(119,156,217,1);

border-radius:21rpx;

margin-left: 20rpx;

font-size:26rpx;

font-weight:800;

color:rgba(255,255,255,1);

}

js:

data: {

// 轮播

slider: [

{ picUrl: 'http://eventimg.oss-cn-shenzhen.aliyuncs.com/guofeng/guofeng_banner.png' },

{ picUrl: 'https://eventimg.oss-cn-shenzhen.aliyuncs.com/pictures/5c0932f3e33e0.png' },

{ picUrl: 'https://eventimg.oss-cn-shenzhen.aliyuncs.com/pictures/5b7642205b63a.jpg' },

],

swiperCurrent: 0,

},

// 轮播

swiperChange: function (e) {

this.setData({

swiperCurrent: e.detail.current

})

},



},

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值