我如何只显示第一行文字?如果我有这样的事情:
<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” 。
最佳答案
您可以使用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>
当达到父 View 的限制时,这将包装您的文本,例如:
Contrary to popular belief, Lorem Ipsum is not...
关于reactjs - 在React Native中仅显示文本的第一行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52865835/