swiper闪屏

发布于 7 年前作者 xiulanduan9181 次浏览最后编辑 7 年前来自 ask

小程序swiper整屏闪动,几个页面轮流显示又不像是来回滚动,但内容一直在变化(没有设置自动播放),不知道是什么问题,出现问题又不是很频繁

测试机型:iPhone SE  版本不限

9 回复
cqian
cqian1 楼6 年前

你可以通过判断是否是由setData导致的change,来决定是否在change事件中再次setData。

pliang
pliang2 楼6 年前

swiperChange中有setData改变current的调用吗?

mhu
mhu3 楼6 年前

搞定了,谢谢QAQ

pshi
pshi4 楼6 年前

请不要这么做。

weipeng
weipeng5 楼6 年前

现在swiper的change事件会返回source字段,表示导致change的原因,请参见
https://mp.weixin.qq.com/debug/wxadoc/dev/component/swiper.html

ming86
ming866 楼6 年前

这个好像只是说明触发的事件,对解决上面的问题好像作用不大

xiulanmeng
xiulanmeng7 楼6 年前

有的

swiperChange: function (e) {
        this.setData({
            tabIndex: e.detail.current
        })
    },
xiulan17
xiulan178 楼6 年前

感谢反馈,麻烦提供一下相关代码和iOS版本。

yong72
yong729 楼5 年前

我也遇到这样的问题。在测试机荣耀5A,微信版本6.5.8。代码如下

<swiper current="{{tabIndex}}" bindchange="swiperChange" class="cont-box" style="height:{{scrHeight}}px;">
    <swiper-item>
      <!--待支付订单列表-->
      <scroll-view scroll-y="true" style="height:{{scrHeight}}px;left:{{-tabIndex*100}}%;" class="order-cont">
        <!--内容省略-->
      </scroll-view>
    </swiper-item>
    <swiper-item>
      <!--待收货订单列表-->
      <scroll-view scroll-y="true" style="height:{{scrHeight}}px;left:{{-(tabIndex-1)*100}}%;" class="order-cont">
   <!--内容省略-->    
      </scroll-view>
    </swiper-item>
    <swiper-item>
      <!--已完成订单列表-->
      <scroll-view scroll-y="true" style="height:{{scrHeight}}px;left:{{-(tabIndex-2)*100}}%;" class="order-cont" bindscrolltolower="moreClose">
        <!--内容省略-->
      </scroll-view>
    </swiper-item>
  </swiper>