【发布时间】:2018-09-02 01:34:38
【问题描述】:
如何将徽章右对齐?
这是我目前拥有的代码:
<View style={{flexDirection: 'row', flex: 1}}>
<Text style={{width: "20%"}}>Room:</Text>
<Text>{this.props.title}</Text>
<Badge value='(1/7)' style={{alignSelf: 'flex-end'}} />
</View>
【问题讨论】:
-
你试过
justifyContent: 'flex-end' -
margin-left:auto?即<Badge value='(1/7)' style={{margin-left: 'auto'}} /> -
margin-left: auto 给出语法错误,而 justifyContent 用于父容器,因此这将证明两个文本元素以及徽章
-
可能很抱歉
<Badge value='(1/7)' style={{marginLeft: 'auto'}} />。 React camelCases kebab-case :)
标签: javascript react-native mobile