美文网首页
Vue+Element ui 根据后台返回数据设置动态表头操作

Vue+Element ui 根据后台返回数据设置动态表头操作

作者: 上海_前端_求内推 | 来源:发表于2022-09-19 17:42 被阅读0次

1,html

<el-table class="tb-edit" highlight-current-row :data="tableData" border style="width: 100%">        
 <template v-for="(col,index) in cols">         
 <el-table-column :prop="col.prop" :label="col.label"></el-table-column>       
 </template>      
</el-table>

2,data

data(): {
  return: {
    cols:[
      {prop: "327", label: "护士"},
      {prop: "328", label: "护理员组长"},
      {prop: "329", label: "护理员"},
      {prop: "330", label: "输单员"}
   ],
   tableData:[
     {327: "24", 328: "20", 329: "18", 330: "2"},
     {327: "22", 328: "20", 329: "18", 330: "2"},
     {327: "22", 328: "20", 329: "18", 330: "2"},
     {327: "51", 328: "21", 329: "20", 330: "6"},
     {327: "21", 328: "20", 329: "18", 330: "2"},
   ]
  }
}

相关文章

网友评论

      本文标题:Vue+Element ui 根据后台返回数据设置动态表头操作

      本文链接:https://www.haomeiwen.com/subject/gfsvortx.html