這里主要利用了circular實(shí)現(xiàn)無限滾動(dòng),然后再加上前后間距,再設(shè)置圖片的層級(jí)和透明度就可以實(shí)現(xiàn)了,將圖片及容器的高度設(shè)置好就差不多可以實(shí)現(xiàn)了
<!--carousel/index.wxml-->
<swiper class="imageContainer" bindchange="handleChange" previous-margin="50rpx" next-margin="50rpx" circular autoplay>
<block wx:for="{{3}}" wx:key="{{index}}">
<swiper-item class="item">
<image class="itemImg {{currentIndex == index ? 'active': ''}}" src="../../../image/3.jpg"></image>
</swiper-item>
</block>
</swiper>
wxss文件
/* carousel/index.wxss */
page{
background: #f7f7f7f7;
}
.imageContainer{
width: 100%;
height: 500rpx;
background: #000;
}
.item{
height: 500rpx;
}
.itemImg{
position: absolute;
width: 100%;
height: 380rpx;
border-radius: 15rpx;
z-index: 5;
opacity: 0.7;
top: 13%;
}
.active{
opacity: 1;
z-index: 10;
height: 430rpx;
top: 7%;
transition:all .2s ease-in 0s;
}
JS文件
// carousel/index.js
Page({
data: {
currentIndex: 0
},
onLoad: function (options) {
},
/* 這里實(shí)現(xiàn)控制中間凸顯圖片的樣式 */
handleChange: function(e) {
this.setData({
currentIndex: e.detail.current
})
},
})
|
正在努力學(xué)習(xí)中,若對(duì)你的學(xué)習(xí)有幫助,留下你的印記唄(點(diǎn)個(gè)贊咯^_^)