css实现
// 单行文本
.item {
width:100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
// 多行文本
.item {
width: 100px;
display: -webkit-box;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
overflow: hidden;
}
js实现
function filterFun(value) {
if (value && value.length > 50) { //字符最大长度
value = value.substring(0, 50) + "..."; //超过省略
}
return value;
}