效果图
效果描述:
只有超出10个字的标题才会显示el-tooltip,没有超出的不会显示
思路:表格中的数据超出10个字显示隐藏,用hover效果显示el-tooltip并显示全部的文字
代码:
<el-table-column label="标题" width="180">
<template slot-scope="scope">
<el-tooltip
class="item"
effect="dark"
:content="scope.row.title"
placement="bottom"
popper-class="tips"
>
<span v-if="scope.row.title.length >= 10">{
{
scope.row.title
}}</span>
</el-tooltip>
<span v-if="scope.row.title.length < 10">{
{
scope.row.title
}}</span>
</template>
</el-table-column>
/deep/.el-table td {
border-bottom: 1px solid #2E2C3D;
background: #242133;
.cell span {
display: block;
width: 10em;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
**提示:**把cell样式里面的em单位换成width也可以实现,具体看需求