table表格标题换行

时间:2024-03-22 19:53:26

table表格标题换行

<el-table :data="tableData" style="width: 100%" max-height="100%">

  <el-table-column :render-header="renderHeader" prop="testDriveDuration" label="试驾时长(分秒)" width="100">

     <template slot-scope="scope">

        <span v-if="scope.row.testDriveDuration">{{scope.row.testDriveDuration}}</span>

        <span v-else>---</span>

     </template>

  </el-table-column>

</el-table>

//表格标题字体换行处理

renderHeader(h, {column, $index}) {

let label = column.label

let str = label.substring(0, 4)

let str2 = label.substring(4, label.length)

return h(

'div',

{style: 'line-height: 20px;text-align: left;padding: 0;'},

[

h(

'div',

{style: 'display:block;line-height: 20px; padding-left:0;'},

str

),

h(

'div',

{

style:

'display:block;line-height: 20px; padding-left:0;text-align: left;'

},

str2

)

]

)

},