Skip to content

Function: truncateText()

ts
function truncateText(
   text, 
   maxLength, 
   ellipsis?): string;

Truncates text with ellipsis. 截断文本并追加省略号。

Parameters

ParameterTypeDefault value
textstringundefined
maxLengthnumberundefined
ellipsisstring'...'

Returns

string

Example

ts
truncateText('Hello World', 8) // => 'Hello...'

Since

1.0.0

Released under the MIT License.