如何对文本产生省略号效果 [英] How to have Ellipsis effect on Text
本文介绍了如何对文本产生省略号效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用中有很长的文本,我需要将其截断并在末尾添加三个点.
I'm having a long text in my app and I need to truncate it and add three dots to the end.
如何在 React Native Text 元素中做到这一点?
How can I do that in React Native Text element?
谢谢
推荐答案
use numberOfLines
use numberOfLines
<Text numberOfLines={1}>long long long long text<Text>
或者如果您知道/或可以计算每行的最大字符数,则可以使用 JS 子字符串.
or if you know/or can compute the max character count per row, JS substring may be used.
<Text>{ ((mytextvar).length > maxlimit) ?
(((mytextvar).substring(0,maxlimit-3)) + '...') :
mytextvar }
</Text>
这篇关于如何对文本产生省略号效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文