swiper的卡顿问题
发布于 5 年前 作者 fanggang 12827 次浏览 来自 问答

swiper 来回左右滑动,滑动7,8次,就会卡死,官方的demo也一样,也会卡死

2 回复

swiper组件在持续优化中,感谢反馈

郁闷啊,

<swiper class="swiper" current="{{currentTab}}" duration="200" bindchange="swiperChange" bindanimationfinish="animationfinish">
        <swiper-item>
            <view id="fist-swiper-item">我是tab1---- index =1</view>
        </swiper-item>
        <swiper-item>
            <view>我是tab2---- index =2</view>
        </swiper-item>
        <swiper-item>
            <view>我是tab3---- index =3</view>
        </swiper-item>
        <swiper-item>
            <view>我是tab4---- index =4</view>
        </swiper-item>
        <swiper-item>
            <view>我是tab5----index = 5</view>
        </swiper-item>
    </swiper>
// swiper 滑动切换
  swiperChange(e) {
    console.log(e.detail.current, 'e.detail.current', e.detail, 'e.detail~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    console.log(this.data.currentTab, '原来 this.data.currentTab-swiperChange~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`')
    var that = this
    if (e.detail.source == 'touch') {
      if (e.detail.current == 0 && that.data.currentTab > 1) {
        that.setData({
          currentTab: that.data.currentTab
        })
      } else if (e.detail.current == 0 && that.data.currentTab == 1) {
        wx.createSelectorQuery().select('#fist-swiper-item').boundingClientRect(function (rect) {
          //rect.id // 节点的ID
          //rect.dataset // 节点的dataset
          //rect.left // 节点的左边界坐标
          console.log(rect.left)
        }).exec()
        console.log(e)
        that.setData({
          currentTab: e.detail.current
        })
      } else {
        that.setData({
          currentTab: e.detail.current
        })
      }
    }
  },
回到顶部