将字符串截断,并在尾部加上特定字符串。
- Source:
Example
str.truncate('Hello world', 6, 'bad boy') // 'Hello bad boy'
str.truncate('Hello world', 5) // 'Hello...'
str.truncate('Hello world', 15) // 'Hello world'
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | 需要截断的字符串 | ||
length |
String | 截断后的字符串长度 | ||
truncateStr |
String |
<optional> |
'...'
|
在尾部加上的特定字符串 |
Returns:
截断后的字符串
- Type
- String