Open a415715165 opened 1 month ago
的确是这样,下拉刷新一次后,之后往上滑动一下,再次下拉才能拉下来,无法直接2次下拉刷新
确定吗,我怎么才能复现呢
listAttribute:(attr)=>{ attr.height = WindowHeight },
这个设置去掉就正常了
这个设置怎么去掉,源码里去掉?
这个设置怎么去掉,源码里去掉?
ListView({ lazyDataSource: this.dataSource, itemLayout: (item, index) => this.itemLayout(item, index), //条目布局 controller: this.controller, //控制器,负责关闭下拉和上拉 onRefresh: () => { this.loadDataSource() }, // onLoadMore:()=>{ // this.controller.finishLoadMore(true) // }, // listAttribute:(attr)=>{ // attr.height = WindowHeight - Number(AppStorage.get('statusBarHeightVp')) - 44 // }, lazyCachedCount:3 }) .layoutWeight(1)
使用中去掉了,设置后就不行
import { ActionBar } from '../ActionBar' import { ListView, RefreshController, RefreshDataSource } from '@abner/refresh'
/**
@Entry @Component struct ListViewUpAndDownLazyPage { controller: RefreshController = new RefreshController() //刷新控制器 lazyDataSource: RefreshDataSource = new RefreshDataSource() //懒加载数据
aboutToAppear() { this.lazyDataSource.initData(this.getArray()) }
private getArray(): Array {
let array: Array = []
for (let i = 0; i < 3; i++) {
array.push(i)
}
return array
}
async getData() { setTimeout(() => { let array: number[] = [];
}
/**
@param index 数据索引 */ @Builder itemLayout(_: Object, index: number): void { Text("测试数据" + index) .width("95%") .height(50) .margin(10) .textAlign(TextAlign.Center) .border({ width: 1, color: Color.Pink }) }
build() { Column() { ActionBar({ title: "刷新加载列表ListView【懒加载】" })
ListView({ lazyDataSource: this.lazyDataSource, itemLayout: (item, index) => this.itemLayout(item, index), isLazyData:true, lazyCachedCount:10, controller: this.controller, //控制器,负责关闭下拉和上拉 onRefresh: () => { this.lazyDataSource.deleteAll(() => { this.lazyDataSource.pushDataArray(this.getArray()) }) //关闭暂无更多数据 // this.controller.isFooterNothing = false this.controller.finishRefresh() }, onLoadMore: (async () => { await this.getData() //上拉加载更多的回调 this.controller.finishLoadMore() }) }) } } }