【类 型】:feat
【原 因】:过滤过长的文本 【过 程】:truncate函数 过滤器 过滤文本 超出长度截掉 替换成省略号 【影 响】: # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
0d82eef864
commit
30094ef819
@ -1,5 +1,17 @@
|
||||
import mqtt from './mqtt.js'
|
||||
import store from '../store/index.js'
|
||||
|
||||
|
||||
/**
|
||||
* 文本过长截取
|
||||
* @param {string} value 文本内容
|
||||
* @param {Number} length 设定长度
|
||||
* @returns {string} 截取完的内容最后加省略号
|
||||
*/
|
||||
export function truncate(value, length = 5) {
|
||||
if (!value) return '';
|
||||
return value.length > length ? value.slice(0, length) + '...' : value;
|
||||
}
|
||||
/**
|
||||
* Parse the time to string
|
||||
* @param {(Object|string|number)} time
|
||||
|
Loading…
Reference in New Issue
Block a user