在列表List1的底部的ListItem中再添加一个List2,当滑动List1时,发现当List2滚到顶部时,List1的ListItem会触发aboutToReuse的方法,触发的个数跟cacheCount的个数一样。
请问为什么会在aboutToRecycle之后,马上出现cacheCount个数ListItem的aboutToReuse。
参考代码如下
List() {
LazyForEach(this.controller.data, (item: BaseTemplate, index: number) => {
ListItem() {
item.getWrappedBuilder().builder(item)
}
},(item: BaseTemplate, index: number)=>{
return item.model.key
})
ListItem() {
List() {
LazyForEach(this.controller.data2, (item: BaseTemplate, index: number) => {
ListItem() {
item.getWrappedBuilder().builder(item)
}
}, (item: BaseTemplate, index: number) => {
return item.model.key
})
}.height('100%').width('100%').backgroundColor(Color.Brown)
}
}.height('100%').width('100%').backgroundColor(Color.Gray).cachedCount(5)
滑过多少个就预加载多少个,保持预加载屏外上下各cachount个item