[英]ItemSeparatorComponent - Call back for each row
我有同样的要求,结果你也可以传递一个函数:
renderSeparator = ({leadingItem, section})=>{
if (section.noSeparator || !leadingItem.noSeparator)
return null;
return <Separator />;
};
render(){
return <SectionList
renderSectionHeader={this.renderSectionHeader}
sections={this.sections}
renderItem={this.renderItem}
ItemSeparatorComponent={this.renderSeparator}
/>;
}
要显示ItemSeparatorComponent
,请制作自己的分隔符或从 react-native 声明内置分隔符。 分隔符需要放在FlatList
正上方,以便它呈现在正确的位置。 分隔符在列表的末尾和开头可见。 下面是FlatList
分隔符代码:
{/* ... */}
render()
{
return(
{/* ... */}
<SeparatorComponent /> //separator component
<FlatList
ItemSeparatorComponent={SeparatorComponent} // assign the separator here
{/* ... */}
/>
)
}
干杯:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.