<div class="dataInfo mb-10">
<el-table
:data="getValues"
:cell-style="cellStyle"
style="width: 100%"
border>
<el-table-column
v-for="(item, index) in getHeaders"
:prop="item"
:key="index"
align="center"
:show-header="false"
></el-table-column>
</el-table>
</div>
data() {
return {
dataInfo: [],
dataInfoHeader: [
{ title: 'Year', field: 'year', },
{ title: 'Month', field: 'month' },
{ title: 'Day count', field: 'dayCount' },
{ title: 'Demoninator',field: 'denominator'}
],
}
},
computed: {
getHeaders() {
return this.dataInfo.reduce((pre, cur, index) => pre.concat(`value${index}`), ['title'])
},
getValues() {
return this.dataInfoHeader.map(item => {
return this.dataInfo.reduce((pre, cur, index) => Object.assign(pre, {['value' + index]: cur[item.field]}), {'title': item.title})
})
}
},