taro-list
taro-list copied to clipboard
上拉加载更多之后,在“没有更多了”的时候异常
您好,感谢分享 参考“虚拟列表”示例,在使用时发现以下2个问题,希望可以抽空update一下
- 多次上拉加载更多之后,在“没有更多了”的时候,提示文字位置异常,感觉是下面这段代码设置itemSize的时候,最后一个非status的item高度也被设置为140rpx
const total = this.dataManager.get().length;
this.dataManager.updateConfig({
itemSize: index => (index === total - 1 ? '140rpx' : '240rpx')
});
- 多次上拉加载更多之后,在“没有更多了”的时候,继续上拉加载更多操作,会出现多个“没有更多了”提示
感谢。目前已更新例子代码, web 已上传。
您好,我这边又遇到一个问题,重现步骤如下: 首次加载->列表成功显示->后台插入一条新数据->下拉刷新->列表不显示该条新数据
经过调试,目前确认
- 后台接口返回了新数据、
- dataManager执行set之后,render函数中打印list(其中也有新数据)
- 尝试了forceupdate,新数据依然不显示
暂时在handleRefresh时加了this.dataManager.clear();
,这样下拉刷新之后能够显示新数据,但是清空列表会闪空白页,体验不太好;
请问有什么办法让list重新渲染一下?
您好,我这边又遇到一个问题,重现步骤如下: 首次加载->列表成功显示->后台插入一条新数据->下拉刷新->列表不显示该条新数据
经过调试,目前确认
- 后台接口返回了新数据、
- dataManager执行set之后,render函数中打印list(其中也有新数据)
- 尝试了forceupdate,新数据依然不显示
暂时在handleRefresh时加了
this.dataManager.clear();
,这样下拉刷新之后能够显示新数据,但是清空列表会闪空白页,体验不太好;请问有什么办法让list重新渲染一下?
是不是最新版本
您好,我这边又遇到一个问题,重现步骤如下: 首次加载->列表成功显示->后台插入一条新数据->下拉刷新->列表不显示该条新数据 经过调试,目前确认
- 后台接口返回了新数据、
- dataManager执行set之后,render函数中打印list(其中也有新数据)
- 尝试了forceupdate,新数据依然不显示
暂时在handleRefresh时加了
this.dataManager.clear();
,这样下拉刷新之后能够显示新数据,但是清空列表会闪空白页,体验不太好; 请问有什么办法让list重新渲染一下?是不是最新版本
是最新版本
这边你可以大概贴一下你的代码
和之前您demo项目里的list代码基本一致
handleRefresh = cb => {
if (this.loadStatus == "refreshing") {
return;
}
this.page = 1;
this.loadStatus = "refreshing";
this.dataManager.clearAllLoadStatus();
this.fetch()
.then(cb)
.then(() => {
this.dataManager.updateConfig({
itemSize: ITEM_SIZE
});
this.loadStatus = "none";
});
};
fetch = (cb?: (data: any[]) => void) => {
return getData(this.page).then(({ data }) => {
const list: any[] = data || [];
if (typeof cb === "function") {
cb(list);
} else {
if (this.page === 1) {
this.dataManager.set(list);
} else {
this.dataManager.push(...list);
}
}
if (list.length) {
this.page += 1;
} else {
this.dataManager.setLoadStatus({
type: "ended"
});
}
});
};
render() {
const { list } = this.state;
const last = list[list.length - 1];
// 解决加载更多时,Android不能自动滚动到最底部
const scrollToIndex = last && last.item.type === 'loadMore' ? last.index : undefined
return (
<TaroList
onRefresh={this.handleRefresh}
onLoadMore={this.handleLoadMore}
virtual
enableBackToTop
scrollWithAnimation
height='95vh'
dataManager={this.dataManager}
scrollToIndex={scrollToIndex}
>
<View className='refund-list-page'>
{list.map((item, index) =>
item.item.type === "loadMore" ? (
<View className='loadStatus' style={item.style}>
加载更多...
</View>
) : item.item.type === "ended" ? (
<View className='loadStatus' style={item.style}>
没有更多了
</View>
) : (
<View
style={{
...item.style
}}
>
<ToFightOrderItem
key={item.item.id}
data={item.item}
onRefundClick={this.refundClick.bind(this, item.item)}
onFightClick={this.fightClick.bind(this, item.item)}
onDetailClick={this.detailClick.bind(this, item.item)}
/>
</View>
)
)}
</View>
</TaroList>
);
}
}
最近有点忙,不好意思。 能提供什么复现demo平台最好了。或者说明 IOS 端还是安卓,Web 还是小程序。