场景
表头不固定,根据后端返回的对象数组取key值为表头,value为行值。
实现
tableLookData为渲染数据,tableLookHeader为表头。
<el-table
:data="tableLookData"
border
class="lookDataTable"
ref="lookDataTable"
@row-dblclick="dblclick"
style="width: 100%; height: 100%"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column
v-for="(head, key) in tableLookHeader"
:label="head"
:key="key"
>
<template slot-scope="scope">
{{ tableLookData[scope.$index][head] }}
</template>
</el-table-column>
</el-table>