Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React Native:如何将文本块放置在行的末尾_React Native_Flexbox - Fatal编程技术网

React native React Native:如何将文本块放置在行的末尾

React native React Native:如何将文本块放置在行的末尾,react-native,flexbox,React Native,Flexbox,我想将文本块放在行的末尾,并在需要时换行,如下所示: 我尝试了很多,但都没有成功,以下是我的代码: <View style={{ flexDirection: 'row', flexWrap: 'wrap', }}> <Text>React native text 1</Text> <Text>React native text 2</Text> <Text>React native text 3<

我想将文本块放在行的末尾,并在需要时换行,如下所示:

我尝试了很多,但都没有成功,以下是我的代码:

<View style={{
  flexDirection: 'row',
  flexWrap: 'wrap',
}}>
  <Text>React native text 1</Text>
  <Text>React native text 2</Text>
  <Text>React native text 3</Text>
</View>

反应本机文本1
反应本机文本2
反应本机文本3
我的结果是:


请问我有什么办法可以做到这一点吗。谢谢

您是否尝试在父文本组件中封装文本?像

<View style={{
  //flexDirection: 'row', //no more needed
  //flexWrap: 'wrap', //no more needed
}}>
  <Text>
    <Text>React native text 1</Text>
    <Text>React native text 2</Text>
    <Text>React native text 3</Text>
  </Text>
</View>

反应本机文本1
反应本机文本2
反应本机文本3

您当前看到了什么?您是否尝试在视图上设置100%的宽度?谢谢,但我不想使用嵌套文本,因为
onLayout
不适用于嵌套文本是的!但是你可以在视图父级上使用它,它的坐标几乎和它的文本子级相同。这只是一个示例,实际上我的视图的子级包含许多文本元素,所以我想知道每个元素的位置