el-table 表格文字后面追加图标(文字超出宽度也不会隐藏图标)个人笔记而已
效果如图
<el-table ref="table" v-loading="loading" :data="roleList">
<el-table-column
label="角色"
prop="username"
width="200"
:show-overflow-tooltip="true"
>
<template slot-scope="{ row }">
<div class="text-wrapper">
<span class="text">{{ row.username }}</span>
<el-button
class="btn"
icon="el-icon-search"
@click="handleButtonClick(row, 1)"
size="mini"
round
></el-button>
</div>
</template>
</el-table-column>
</el-table>
样式 scss
.text-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
width: 150px; /* 注意这里必须设置宽度 */
}
.text {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.btn {
min-width: 0;
margin-left: 10px;
}
.el-button--mini.is-round {
border: none;
}