swiper通过设置current切换页面,circular衔接效果失效
发布于 6 年前 作者 ghao 15363 次浏览 来自 问答
<view>
    <swiper circular="{{true}}" current="{{currentTap}}">
        <swiper-item>
            <text>11111111</text>
        </swiper-item>
        <swiper-item>
            <text>2222</text>
        </swiper-item>
        <swiper-item>
            <text>3333</text>
        </swiper-item>
    </swiper>
    <view style="display:flex;height:100rpx">
        <button catchtap="preBtn">上一页</button>
        <button catchtap="nextBtn">下一页</button>
    </view>
</view>
data: {
    currentTap: 0
},
preBtn: function () {
    let newTap = 0;
    if (this.data.currentTap == 0) {
        newTap = 2;
    } else if (this.data.currentTap == 1) {
        newTap = 0;
    } else if (this.data.currentTap == 2) {
        newTap = 1;
    }
    console.log('点击上一页 newTap:' + newTap + '  currentTap:' + this.data.currentTap)
    this.setData({
        currentTap: newTap
    })
},
nextBtn: function () {
    let newTap = 0;
 
    if (this.data.currentTap == 0) {
        newTap = 1;
    } else if (this.data.currentTap == 1) {
        newTap = 2;
    } else if (this.data.currentTap == 2) {
        newTap = 0;
    }
    console.log('点击下一页 newTap:' + newTap + '  currentTap:' + this.data.currentTap)
    this.setData({
        currentTap: newTap
    })

},


swiper组件设置circular衔接滑动时,手势左右滑动可达到衔接效果;

但是当通过设置current属性时,一直点击下一页,没有衔接效果;

2 回复

感谢反馈。这里其实是因为设置current属性时,信息不足以判断应当向左滚动还是向右滚动。我们会考虑看看怎么优化这个问题。

@LastLeaf 好的,辛苦了

回到顶部