如何仅显示第一行文字?如果我有这样的东西:
<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” 。
答案 0 :(得分:1)
您可以使用道具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...
答案 1 :(得分:0)
您可以创建一个特殊的Text组件,该组件仅呈现分配值的子字符串。