this.dataSource是通用的数据源,瀑布流中的仅需dataSource中支持瀑布流的组件item,业务上需要过滤其他Item,但如果通过下述代码实现过滤,相当于没有设置FlowItem的子模块,但仍会存在空白区域(空白区域是因为columnsGap和rowsGap照成的),如何实现LazyForEach过滤无用的item且不留空白呢?
伪代码:
WaterFlow( ) {
LazyForEach(this.dataSource, (item: NewsItem, index: number) => {
FlowItem() {
if(item.isWaterFlowType){
NewsItemJiMeiNormalCardComponent({
newsItem: newsItem,
onNewsItemClick: this.onNewsItemClick,
onNewsItemChildClick: this.onNewsItemChildClick
})
}
}
})
}
backgroundColor: Color.White,
columnsTemplate: '1fr 1fr',
rowsTemplate: '1fr',
columnsGap: 10,
rowsGap: 10,
建议筛选并重新生成新的数据源给LazyForEach,以下是通过改样式达到效果,用了margin替代rowsGap: