如何在 React Native 中使 2 个 <Text> 内联

Posted

技术标签:

【中文标题】如何在 React Native 中使 2 个 <Text> 内联【英文标题】:How to make 2 <Text> inline in React Native 【发布时间】:2022-01-06 06:56:04 【问题描述】:

我想在一行中制作 2 个,一个 flex-end 和一个 flex-start,但是在将 flex-endflex-start 分别应用于这两个之后,我无法使其内联。有人知道怎么做吗?

<View style=flexDirection: 'row'>
   <Text style=alignSelf: 'flex-start'>Line 1</Text>
   <Text style=alignSelf: 'flex-start'>Line 2</Text>
</View>

【问题讨论】:

【参考方案1】:

只需使用justifyContent:'space-between'即可,无需使用Text中的任何内容

<View style=flexDirection: 'row', justifyContent:'space-between'>
   <Text>Line 1</Text>
   <Text>Line 2</Text>
</View>

【讨论】:

以上是关于如何在 React Native 中使 2 个 <Text> 内联的主要内容,如果未能解决你的问题,请参考以下文章