swiper组件在触底事件onReachBottom中使用setData渲染界面失败

<swiper class='swiper' style='height:{{swiper_height}}px;' bindchange="swiperChange" current='{{current_id}}'>
      <swiper-item>
        <view class='movement-height' animation="{{opaIn}}">
            <scroll-view style="height:{{swiperHeight}}px;" scroll-y="true" bindscrolltolower="loadMoreData">
              <view wx:for="{{list}}" wx:for-item="listItem" wx:for-index="listIndex" wx:key="listIndex">
                <view wx:for="{{listItem}}" wx:for-index="myIndex" wx:for-item="myItem" wx:key="id">
                  <block wx:if="{{myItem.type=='2'}}">
                    <view class="content">
                      <view class="left-content">
                        <view class="image">
                          <image src="{{serverUrl}}{{myItem.user.image}}" data-old='{{myItem.open_id}}' bindtap="userNavFun"></image>
                        </view>
                        <view class="center-title">
                          <view class="cnt-title">
                            <text class='name'>{{myItem.user_nick}}</text>
                            <text class='attention'>关注了你</text>
                            <text class="time">{{myItem.time}}</text>
                          </view>
                        </view>
                      </view>
                     
                    </view>
                  </block>
                </view>
              </view>
            </scroll-view>
        </view>
      </swiper-item>
    </swiper>
onLoad: function (options) {
    const that = this;
    wx.getSystemInfo({
      success: function (res) {
        let scrollH = res.windowHeight;
        that.setData({
          swiperHeight: scrollH
        });
      }
    });
    this.getUserLikePost();
  },
getUserLikePost:function(){
    const that = this;
    wx.request({
      url: app.globalData.basePath + 'user_like_content',
      data: {
        pageIndex: that.data.activityPage,
        openId: '***********************'
      },
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        if(res.data.list ==null ||res.data.list.length<=0){
          wx.showToast({
            title: '已经到底啦...',
            duration: 1000
          })
        }else{
          var nowPost = res.data.list;
          var pageNum = that.data.activityPage-1;
          that.setData({
            ['list['+pageNum+']']: nowPost,//如果数据不能填充的高度小于scroll-view的高度,便不能触发bindscrolltolower事件
            activityPage: that.data.activityPage+1
          })
        }
        console.log(that.data.list);
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  loadMoreData:function(e){
    this.getUserLikePost();
  }

1 直接修改this.data,而不调用this.setData(),是无法改变当前页面的状态的,会导致数据不一致
2 仅支持可以JSON化的数据
3 单次设置的数据不能超过1024KB,尽量避免一次设置过多的数据
4 不要把data中的任何一项的value设为undefined,否则这一项将不能被设置,可能会有潜在的问题
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值