微信小程序swiper如何获得当前页面的index

来源:互联网 发布:吸烟有害健康烟盒 知乎 编辑:程序博客网 时间:2024/06/07 00:25

想要实现的效果:(滑动时显示当前页面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    })  },



原创粉丝点击