码迷,mamicode.com
首页 > 微信 > 详细

小程序实现一个简单的swiper

时间:2019-12-27 13:20:55      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:rip   bsp   wip   image   asc   width   index   lda   src   

话不多说,上截图

技术图片

 

 

 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‘ : ‘‘}}" />    
    </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,
    })
  },

  

小程序实现一个简单的swiper

标签:rip   bsp   wip   image   asc   width   index   lda   src   

原文地址:https://www.cnblogs.com/HopeInTheDark/p/12106532.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!