React native 如何将子视图设置为“自动填充”;“其他轴”;母公司的';在react native中的s弯曲方向?

React native 如何将子视图设置为“自动填充”;“其他轴”;母公司的';在react native中的s弯曲方向?,react-native,flexbox,React Native,Flexbox,例如,我有这样的布局: <View style={{ flexDirection: "column", width: 200, height: 200, backgroundColor: "gray" }}> <View style={{ flex: 1, width: 50, backgroundColor: "red" }}/> <View style={{ flex: 1, width: 50, backgroundColor: "blue"

例如,我有这样的布局:

<View style={{ flexDirection: "column", width: 200, height: 200, backgroundColor: "gray" }}>
    <View style={{ flex: 1, width: 50, backgroundColor: "red" }}/>
    <View style={{ flex: 1, width: 50, backgroundColor: "blue" }}/>
</View>

这将生成两个小矩形,每个矩形的宽度为50,高度为100。由于flex 1和“column”的父flexDirection,高度自动设置为100


我的问题是,如何使红色和蓝色矩形的宽度自动跟随父矩形的宽度?当然,我不能在child上使用“flex”,因为flex是为垂直轴保留的,因为父flexDirection“column”。我对CSS和react native都很陌生,所以这个flex系统让我很困惑。

只需从孩子身上删除
width
components@VilleKoo是的。。。你可以看看快餐项目。。。也许可以通过使用此功能提高flexbox知识,谢谢,我没有意识到在flex显示中,子组件将默认遵循父组件的交叉flexDirection。FlexboxFrogy也有帮助!和FlexboxFrogy一样,我发现自己也经常提到这一点。好的视觉指南:)