微信小程序swiper如何獲得當前頁面的index

想要實現的效果:(滑動時顯示當前頁面index)

看小程序的官方文檔

代碼:index.wxml

  <swiper class='sw-tu' circular="true" current="0" bindchange='onSlideChangeEnd'>
    <swiper-item class="sw-tuone" wx:for="{{list.img2}}">
      <image class='sw-photo' src="{{item}}" />
    </swiper-item>
  </swiper>

index.js

data: {
    index: 1,
  },
  onSlideChangeEnd: function (e) {
    var that = this;
    that.setData({
      index: e.detail.current + 1
    })
  },



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章