【发布时间】:2018-05-18 13:46:04
【问题描述】:
我有一个类似网格的FlatList,它是 3x3。我希望根据容器(屏幕)宽度均匀分布 3 列。在正常情况下,这将由justifyContent: 'space-between' 完成,但是当通过contentContainerStyle 使用时,这不会做任何事情。
<FlatList
contentContainerStyle={{ justifyContent: 'space-between' }}
horizontal={false}
scrollEnabled={false}
numColumns={3}
data={this.props.icons}
extraData={this.props.selectedIcon}
renderItem={this.renderItem}
keyExtractor={this.keyExtractor}
/>
如您所见,图标都被推到左边。
【问题讨论】:
-
我不熟悉 React Native 的语法,但是你有没有将父级声明为
display: flex?另外,space-between周围是否需要引号?
标签: reactjs react-native flexbox