<template v-for="(column, index) in columns">
<el-table-column
:key="index"
:label="column.label"
:prop="column.prop"
:width="column.width ? column.width : 'auto'"
:render-header="renderheader"
>
<template slot-scope="scope">
{{ scope.row[column.prop] }}
<span class="unit">{{ column.danwei }}</span>
</template>
</el-table-column>
</template>

加上 ​​:render-header="renderheader"​

methods

renderheader(h, { column, $index }) {
return h("div", {}, [
h("div", {}, column.label.split(",")[0]),
h("div", {}, column.label.split(",")[1]),
]);
},
// 列表字段对应
columns: [
{
label: '姓名',
prop: 'name',
},
{
label: '年龄',
prop: 'age',
},
{
label: '地址,(具体到区)',
prop: 'adress',
},
]

[element-ui] el-table表头换行_字段






参考:

​​el-table表头换行​​