Reactjs 仅显示React Native中的第一行文本

Reactjs 仅显示React Native中的第一行文本,reactjs,react-native,Reactjs,React Native,如何仅显示文本的第一行?如果我有这样的东西: <View> <Text> Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin pr

如何仅显示文本的第一行?如果我有这样的东西:

<View> 
  <Text>
    Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, 
  </Text>
</View>

与流行的观点相反,Lorem Ipsum不是简单的随机文本。它起源于公元前45年的一段古典拉丁文学,距今已有2000多年的历史。弗吉尼亚州汉普顿悉尼学院的拉丁语教授理查德·麦克林托克(Richard McClintock)查找了一个更为晦涩的拉丁语单词,

我只想“与流行观点相反,Lorem Ipsum”出现。

您可以创建一个专门的文本组件,只呈现指定值的子字符串。

您可以使用prop
numberOfLines
来限制文本溢出:

<Text numberOfLines={1}>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, 
</Text>

在提问之前阅读文档:你不需要导入任何东西,只要使用它!
 Contrary to popular belief, Lorem Ipsum is not...