Recycle-View ctx.update() 和 this.setData()问题?
发布于 4 年前 作者 chao28 11967 次浏览 来自 官方Issues

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

this.setData({ 
   recycleList: current_list
})

请问,有何解决方案?

2 回复
this.ctx.splice(0, this.data.recycleList.length,current_list)

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

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

回到顶部