这是我对SectionList的numColumns的解决方案.如果你有更好的请告诉我.
原文链接:https://www.f2er.com/react/300666.htmlclass Example extends Component { static propTypes = { numColumns: PropTypes.number }; static defaultProps = { numColumns: 2 }; _renderSection = data => <Section {...data} />; _renderItem = ({ section,index }) => { const { numColumns } = this.props; if (index % numColumns !== 0) return null; const items = []; for (let i = index; i < index + numColumns; i++) { if (i >= section.data.length) { break; } items.push(<Item item={section.data[i]} />); } return ( <View style={{ flexDirection: "row",justifyContent: "space-between" }} > {items} </View> ); }; render() { return ( <SectionList sections={dumyData} style={styles.container} renderItem={this._renderItem} renderSectionHeader={this._renderSection} /> ); } }