限制 NativeBase 文本的长度
Limit the length of NativeBase text
我使用 NativeBase
文本组件,我想按字符限制它。例如,它只显示前 10 个字符。
怎么做?
<Text numberOfLines={1} ellipsizeMode='head'>your very long text goes here <Text>
允许的模式是 head, tail, middle,clip
使用切片函数:
var str = "012345678911111111";
var res = str.slice(0, 10);
输出:
0123456789
我使用 NativeBase
文本组件,我想按字符限制它。例如,它只显示前 10 个字符。
怎么做?
<Text numberOfLines={1} ellipsizeMode='head'>your very long text goes here <Text>
允许的模式是 head, tail, middle,clip
使用切片函数:
var str = "012345678911111111";
var res = str.slice(0, 10);
输出:
0123456789