Element UI 表格 el-table-column 宽度自适应不换行设置
<template>
<el-table :data="tableData">
<el-table-column prop="name" label="姓名" fixed="true">
<template slot-scope="scope">
<div class="cell-content">{{ scope.row.name }}</div>
</template>
</el-table-column>
</el-table>
</template>
<style>
.cell-content {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<p>在上面的示例中,我们在 el-table-column 中设置了 fixed 属性为 "true",使列宽固定。然后在 slot-scope 中使用一个包裹元素,设置其 CSS 样式为 white-space: nowrap;,这样文本就不会换行。同时,我们还设置了 overflow: hidden; 和 text-overflow: ellipsis; 来处理文本溢出的情况,显示省略号。</p>
<p>请根据你的具体需求调整以上代码。</p>
原文地址: https://www.cveoy.top/t/topic/ptnj 著作权归作者所有。请勿转载和采集!