1、HTML处理
使用 text-overflow: ellipsis
.ellipsis{
/*设置显示宽度*/
white-space: nowrap; /*文本不换行。*/
overflow: hidden; /* 超过部分隐藏*/
text-overflow: ellipsis; /*超过部分用...代替*/
cursor: pointer; /* 鼠标设置(不是必须)*/
}
如果要查看整个字符串,可以引用popover
<script src="/static/common/js/popover.js"></script>
<tr class='file_name'>
<td class="ellipsis" data-toggle="popover" data-content="{{ your value}}" data-placement="bottom" data-container="body" >your text</td>
</tr>
2、js处理
使用.substr()函数截取
var questionDescBrief=null;
var questionsDesc=vm.questionsDesc;
//如果字符长度超过50,后面的字符就变成...可自行调整长度和代替字符
if(questionsDesc.length > 50) {
//截取从第一个字符开始,往后取50个字符,剩余的用...代替
questionDescBrief=questionsDesc.substr(0,50) + "..."
}else {
questionDescBrief=questionsDesc;
}