gpt4 book ai didi

reactjs - 在 React Native 中仅显示第一行文本

转载 作者:行者123 更新时间:2023-12-03 13:28:53 25 4
gpt4 key购买 nike

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

<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”出现。

最佳答案

您可以使用属性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>

当达到父 View 的限制时,这将使您的文本换行,例如:

 Contrary to popular belief, Lorem Ipsum is not...

关于reactjs - 在 React Native 中仅显示第一行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52865835/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com