AbnerMing888 / HarmonyOsRefresh

HarmonyOsRefresh是一个鸿蒙版的刷新组件,超简单使用,支持下拉刷新和上拉加载,支持各种组件,List、Grid、Column、Row……
Apache License 2.0
180 stars 22 forks source link

直接替换数据源导致页面卡顿。 #190

Open renwavewave opened 1 month ago

renwavewave commented 1 month ago

我的列表一共有不到200条数据,进行关键字搜索后变成10条,这样正常。取消搜索后10条变成200条的时候页面会卡顿。 我是先调用 deleteAll 删除所有数据然后再 push进去新数据。这样会导致页面卡顿。请问该如何处理呢?

ListView({ lazyCachedCount:5, lazyDataSource: this.vm.dataArray, itemLayout: (item, index) => this.getListView(item as OrderModel, index), controller: this.vm.controller, swipeRightMenuLayout: (index: number) => { //侧滑视图 this.slideRightMenuLayout(index, this.vm.dataArray.getData(index) as OrderModel) }, showEmptyLayout: this.vm.showEmpty || this.vm.showSearchEmpty, emptyLayout: () => this._emptyLayout(), enableLoadMore: false, showLoadingLayout: this.vm.showLoading, loadingLayout: () => this.loadingLayout(), onRefresh: () => { this.vm.getOrders() this.vm.controller.finishRefresh() //关闭下拉刷新,在数据请求回后进行关闭 }, listAttribute: (attribute: ListAttr) => { attribute.divider.strokeWidth = 0.5 attribute.divider.color = '#e0e0e0' attribute.divider.startMargin = 15 } }).height('100%') .width('100%')

renwavewave commented 1 month ago

ListView({ lazyCachedCount:5, lazyDataSource: this.vm.dataArray, itemLayout: (item, index) => this.getListView(item as OrderModel, index), controller: this.vm.controller, swipeRightMenuLayout: (index: number) => { //侧滑视图 this.slideRightMenuLayout(index, this.vm.dataArray.getData(index) as OrderModel) }, showEmptyLayout: this.vm.showEmpty || this.vm.showSearchEmpty, emptyLayout: () => this._emptyLayout(), enableLoadMore: false, showLoadingLayout: this.vm.showLoading, loadingLayout: () => this.loadingLayout(), onRefresh: () => { this.vm.getOrders() this.vm.controller.finishRefresh() //关闭下拉刷新,在数据请求回后进行关闭 }, listAttribute: (attribute: ListAttr) => { attribute.divider.strokeWidth = 0.5 attribute.divider.color = '#e0e0e0' attribute.divider.startMargin = 15 } }).height('100%') .width('100%')

AbnerMing888 commented 1 month ago

200条数据时一下加载进来的吗?如果数据太多,尽量给list设置高度