swiper组件取消自动播放,获取当前的current出现bug
1页面
<checkbox-group bindchange=“checkboxChange”>
<checkbox value=“1” checked=“” />自动播放
</checkbox-group>
<swiper autoplay=“{{autoplay}}” bindchange=“handleSwiper” interval=“5000” current=“{{current}}” circular=“true”>
<swiper-item wx:key=“unique” wx:for=“{{dataList}}” >
<view>
<text>{{ item.title }}</text>
</view>
</swiper-item>
</swiper>
2 js
Page({
data: {
autoplay: false,
current: 0
},
/**
*监听checkbox事件
*/
checkboxChange: function (e) {
var that = this
that.setData({
autoplay: false
})
}
console.log(that.data.current)
}
handleSwiper: function(e){
var that = this
that.setData({
current: e.detail.current
})
}
3问题描述: 取消自动播放,获取当前current跟Wxml中的current不一致,即是有时候出现执行了checkbox事件,handleSwiper还会执行handleSwiper事件。
