iview-weapp icon indicating copy to clipboard operation
iview-weapp copied to clipboard

i-sticky 在onReachBottom之后动态增加i-sticky-item,title会错位显到成下(约3)个的title并不是本身的title

Open tonyguan1981 opened this issue 6 years ago • 4 comments

code如下:

tonyguan1981 avatar Dec 12 '18 15:12 tonyguan1981

let App = getApp(); Page({

/**

  • 页面的初始数据 */ data: { scrollTop: 0, lastperiodid: '', list:[] },

/**

  • 生命周期函数--监听页面显示 */ onShow: function() { this.getUserAccountList(); }, getUserAccountList: function() { let $this = this, periodid = '';
App.util.request({
  'url': 'entry/wxapp/user',
  'data': {
    'op': 'getUserAccountList',
    'account': '113101',
    'periodid': $this.data.lastperiodid
  },
  success: function(res) {
    periodid = res.data.data.list[res.data.data.list.length - 1].periodid;
    $this.setData({
      list: $this.data.list.concat(res.data.data.list),
      lastperiodid: periodid
    });
   
  }
})

},

/**

  • 页面上拉触底事件的处理函数 */ onReachBottom: function() { this.getUserAccountList(); },

//页面滚动执行方式 onPageScroll(event) { this.setData({ scrollTop: event.scrollTop }) } })

tonyguan1981 avatar Dec 12 '18 15:12 tonyguan1981

image

tonyguan1981 avatar Dec 12 '18 15:12 tonyguan1981

解决了吗?动态添加数据感觉都有这个bug

yourVictor avatar Mar 18 '19 10:03 yourVictor

修改组件的代码: 1.找到 iview/sticky/index.js 52行的 item.updateDataChange(index); 修改为 item.updateDataChange(index, this.data.scrollTop); 即传入正在实时变化的滚动条位置

2.找到 iview/sticky-item/index.js 26行的 updateDataChange(index) 修改为 updateDataChange(index, scrollTop) 32行的 top : res.top修改为 top : res.top + scrollTop, 即拿到当前的滚动条位置,初始化新增数据的位置

WeiBanXian avatar Jun 14 '19 00:06 WeiBanXian