vue + element ui 动态添加table数据
html为
<el-table :data="tableData" align='center' border style="width: 100%" :highlight-current-row='true' stripe>
<template v-for="(col ,index) in clinic_idArr">
<el-table-column :prop="col.prop" :label="col.label" :key="index" :width="clinic_idArr.length>15?'140':''" style="color:#fff"></el-table-column>
</template>
</el-table>
数据处理:
this.clinic_idArr = []
this.tableData = []
if(response.data.data.clinic_id.length>0){
for ( var i = 0; i <response.data.data.clinic_id.length; i++){
let childItem = {
label: response.data.data.clinic_id[i],
prop: response.data.data.clinic_id[i]
}