如何在react native中显示带文本的按钮

thtygnil  于 2023-03-09  发布在  React
关注(0)|答案(2)|浏览(113)

假设在react native的text标签中有很多文本,那么我想在这个文本的末尾添加一个按钮(更多)。

<View style={styles.container}>
  {" "}
  <Text style={styles.paragraph}>
    {" "}
    Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    Lorem Ipsum has been the industry's standard dummy text ever since the
    1500s, when an unknown printer took a galley of type and scrambled it to
    make a type specimen book. It has survived not only five centuries, but also
    the leap into electronic typesetting, remaining essentially unchanged. It
    was popularised in the 1960s with the release of Letras{" "}
  </Text>{" "}
  <Pressable>
    {" "}
    <Text>more</Text>{" "}
  </Pressable>{" "}
</View>;

我可以使用pressable,但它是一个块元素,我希望它是内联的。这样文本和按钮就可以呆在一起。

rnmwe5a2

rnmwe5a21#

你可以使用react-native-read-more库来代替自己做。但是,如果你想学习如何做。我强烈建议你去这个库,阅读它应该如何做:)

bjg7j2ky

bjg7j2ky2#

用一个顶级Text组件 Package 所有TextPressable组件,所有组件都是内联的。

<Text>
  <Text>
...
  </Text>
  <Pressable>
    <Text>more</Text>
  </Pressable>
  <Text>
...
  </Text>
</Text>

相关问题