微信小程序 Utils丨Swiper 实现轮播图


JS

that.setData({
    slider: ['../../images/img01.jpg', '../../images/img02.jpg','../../images/img03.jpg']
})

WXML

<swiper id='sw' autoplay="auto" interval="5000" duration="500" indicator-dots='true' indicator-color='#00B26A'>
  <block wx:for="{{slider}}" wx:key="id">
    <swiper-item>
      <image src='{{item}}'></image>
    </swiper-item>
  </block>
</swiper>

WXSS

#sw {
  width: 100%;
  height: 276rpx;
}

#sw swiper-item {
  height: 100%;
  width: 100%;
}

#sw swiper-item image {
  height: 100%;
  width: 100%;
}

更多可设定项

swiper 直通车


猜你喜欢

转载自blog.csdn.net/qq_15609303/article/details/101762831