关于javascript:vueel动态列

3次阅读

共计 417 个字符,预计需要花费 2 分钟才能阅读完成。

效果图

后端返回の数据结构

返回的 result.labelList 是动静 label。result.list,蕴含所有数据,其中 labelMap 是动静列的键值对后果。

前端 HTML

*template 很重要~~

<el-table-column
   v-for="label in labelArr"
   :key="label"
   :label="label"
  >
    <template slot-scope="scope">
      <span>{{scope.row.labelMap[label] }}</span>
     </template>
   </el-table-column>

前端 JS

this.labelArr = [];
this.$set(this, "labelArr", res.result.labelList);
this.$set(this, `${which}`, res.result.list);
正文完
 0