用于对字符串进行截断处理。当超过限定长度(默认是 30),默认添加 3 个点号。
目标字符串
限定长度
省略符
截断后的字符串;未超过限定长度时返回原字符串。
0.0.1
truncate('hello world', 5) // 'he...'truncate('hello world', 300) // 'hello world'truncate('hello world', 8, '--__') // 'hell--__'truncate('hello world hello world hello world') // 'hello world hello world hel...' Copy
truncate('hello world', 5) // 'he...'truncate('hello world', 300) // 'hello world'truncate('hello world', 8, '--__') // 'hell--__'truncate('hello world hello world hello world') // 'hello world hello world hel...'
用于对字符串进行截断处理。当超过限定长度(默认是 30),默认添加 3 个点号。