完成大体功能和样式
This commit is contained in:
16
common/utils/text.js
Normal file
16
common/utils/text.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 文本省略处理
|
||||
* @param {String} text 原始文本
|
||||
* @param {Number} maxLen 最大显示字数
|
||||
* @param {String} suffix 省略后缀,默认 ...
|
||||
* @returns {String}
|
||||
*/
|
||||
function ellipsisText(text, maxLen = 20, suffix = '...') {
|
||||
if (!text) return '';
|
||||
if (text.length <= maxLen) return text;
|
||||
return text.slice(0, maxLen) + suffix;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ellipsisText
|
||||
};
|
||||
Reference in New Issue
Block a user