javascript - React-native:textAlign: 'right' 样式不正确

标签 javascript css text react-native

我对 react-native css-styling 很陌生.. 并且有以下代码:

 <Text>
<Text style={(styles.author, { textAlign: "left" })}>
    {question.view_count + " views\t" + question.comment_count}
    {question.comment_count > 1 || question.comment_count == 0
        ? " comments"
        : " comment"}
</Text>
<Text style={{ textAlign: "right" }}>
    {question.solution_count > 0
        ? question.solution_count + " solutions"
        : " Solve this"}
</Text>
</Text>;

问题是第二个“textAlign: 'right' ”不起作用 - 文本仍在左侧。我希望文本位于同一行,但(显然)右侧的第二个文本对象。

有什么提示吗?谢谢!

编辑 输出如下所示: Screenshot

最佳答案

解决方法-

<View style={{flex: 1, flexDirection: 'row'}}>
  <View style={{flex: 1}}>
    <Text>4 Views 0 Comments</Text>
  </View>
  <View style={{flex: 1}}>
    <Text style={{textAlign: 'right'}}>Solve This</Text>
  </View>
</View>

关于javascript - React-native:textAlign: 'right' 样式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38917002/

相关文章:

javascript - JavaScript 中的 href 递增、递减

css - 澄清 CSS 的动态高度框

HTML/CSS : Show full size image on click

jQuery 文本颜色变化动画

pdf - 从 Gmail 获取 pdf 附件作为文本

html - 将文本输入框对齐到 div 的右侧

右键单击新选项卡时,Javascript 不执行

Javascript 正则表达式不匹配空格

javascript - 子路由在延迟加载中不起作用

css - rails 5 : check box tag showing up two times