微信小程序實現一個簡單swiper代碼實例
更新時間:2019年12月30日 11:55:05 作者:暮雪上的晨星
這篇文章主要介紹了微信小程序實現一個簡單swiper代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
這篇文章主要介紹了微信小程序實現一個簡單swiper代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
話不多說,上截圖
HTML
<swiper class="swiper-block" previous-margin="70rpx" next-margin="70rpx" current="0" autoplay="true" bindchange="swiperChange" circular="true"> <block wx:for="{{totalData.banners}}" wx:index="{{index}}" wx:key="bannerList"> <swiper-item class="swiper-item"> <image mode="aspectFill" src="{{item.cover}}" class="slide-image {{swiperIndex == index ? 'active' : ''}}" /> <br> </swiper-item> </block> </swiper>
css
.swiper-block { height: 320rpx; width: 100%; } .swiper-item { display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: unset; text-align: center; } .slide-image { height: 230rpx; width: 526rpx; border-radius: 10rpx; box-shadow: 0px 3px 10px 0px rgba(51, 51, 51, 0.3); margin: 0 rpx 30rpx; z-index: 1; } .active { transform: scale(1.21); transition: all 0.2s ease-in 0s; z-index: 20; }
js
swiperChange(e) { const that = this; that.setData({ swiperIndex: e.detail.current, }) },
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
javascript模擬的Ping效果代碼 (Web Ping)
JS雖然發(fā)送不了真正Ping的ICMP數據包,但Ping的本質仍然是請求/回復的時間差,HTTP自然可以實現此功能.2011-03-03