自定义轮播图
<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
})
},
还没有评论,来说两句吧...