Recycle-View ctx.update() 和 this.setData()问题?

发布于 6 年前作者 chao2812252 次浏览最后编辑 6 年前来自 issues

当原来列表数据有20条,调用Recycle-View ctx.update(0, current_list) 更新数据,如果current_list只有4条(不满20)时,只能更新前几条,有无办法实现类似setData({})效果

this.setData({ 
   recycleList: current_list
})

请问,有何解决方案?

2 回复
ping45
ping451 楼4 年前
this.ctx.splice(0, this.data.recycleList.length,current_list)

用这样的方式不知道是不是最佳实践。虽然效果能满足。

juan27
juan272 楼4 年前

你这个应该是赋值失败了,在方法里面你当前的this指向已经变更了,建议在方法最上方定义一个var that = this 然后 that.setData