限制NativeBase文本的长度

问题描述 投票:0回答:2

我使用NativeBase文本组件,我想按字符限制它。例如,它仅显示前10个字符。

怎么做?

android ios reactjs react-native native-base
2个回答
0
投票

使用切片功能:

var str = "012345678911111111"; 
var res = str.slice(0, 10);

输出:

0123456789


0
投票
<Text numberOfLines={1} ellipsizeMode='head'>your very long text goes here <Text>

允许的模式是head, tail, middle,clip

Read more

© www.soinside.com 2019 - 2024. All rights reserved.