【发布时间】:2018-03-22 17:44:11
【问题描述】:
我想连续渲染 7 个宽度相等的按钮以水平填充所有可用空间。
render() {
return (
<FlatList
data={this.state.days}
renderItem={({ item }) => <View style={styles.button}><Button title={item.getDate().toString()} /></View>}
keyExtractor={item => item.getDate().toString()}
horizontal={true}
style={styles.list}
/>
);
}
const styles = StyleSheet.create({
list: {
display: 'flex'
},
button: {
flex: 1
}
});
它们在一个平面列表中,包裹在一个视图中,因为我不能直接设置按钮样式。 在 HTML 页面的常规 flexbox 中,这种方法有效。
这是我在 React Native 中得到的:
也许有一些我不熟悉的平面列表行为?
【问题讨论】:
标签: javascript react-native react-native-flexbox