【发布时间】:2019-07-10 09:44:22
【问题描述】:
我一直在通过使用我需要的 flex 创建空视图组件来设置 flexbox 的边距,但我想知道是否有一种方法可以更优雅地做到这一点。这是我一直在做的事情:
const MyComponent = () => (
<View style={{ flex: 1, justifyContent: 'space-around', alignItems: 'center'}}>
<View style={{ flex: 1 }} />
<View style={{ flex: 1 }}>
<Text>My real content here</Text>
</View>
</View>
);
请注意,我只是放置了第一个内部视图以提供我想要的适当边距。有没有一种优雅(又名正确)的方式来做到这一点?
【问题讨论】:
标签: javascript css react-native