赞
踩
效果图
效果描述:
只有超出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也可以实现,具体看需求
<el-table-column label="详情描述" align="center" width="100px"> <template slot-scope="scope"> <el-tooltip class="item" effect="dark" placement="bottom" popper-class="tips" > <template slot="content"> <p style="max-width: 1000px">{{ scope.row.description }}</p> </template> <span style="max-width: 60%" v-if="scope.row.description.length >= 5" >{{ scope.row.description.slice(0, 5) + "..." }}</span > </el-tooltip> <span v-if="scope.row.description.length < 5">{{ scope.row.description }}</span> </template> </el-table-column>
通过template标签插槽添加提示语,便于给提示语添加布局改变数据结构或是样式
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。