swiper 组件 bindchange中调用setData,原先数据也会被渲染
发布于 6 年前 作者 moqiang 7727 次浏览 来自 问答

在swiper 组件的 bindchange中调用setData()方法,没有改变的数据也会被重新渲染。

例如我只改变数据swipercurrentindex的值。

changswiperindex: function (event){
    this.setData({
      swipercurrentindex: event.detail.current
    })
  },

但是页面中其他的数据如recommendarray也被重新渲染,导致以下for循环执行。

<view class="recommendationview" wx:for="{{recommendarray}}" wx:key="id" >

回到顶部