element-ui 动态表格(el-table)

做pc端开发的时候,有好几个弹窗展示同一种样式的table,记录一下。

<el-dialog
        :title="titleName"
        :visible.sync="dialogChangeVisible"
        top="30vh"
        :close-on-click-modal="false">
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            :prop="item.column_name"
            :label="item.column_comment"
            :width="item.width===null?'auto':item.width"
            :key="key"
            align="center"
            v-for="(item, key) in headData">
            <template slot-scope="scope"><!--可自定义显示的内容-->
            <!--可忽略-->
              <div v-if="scope.column.property !== 'financeType'">		
              	{{scope.row[scope.column.property]}} 
              </div>
               <!--可忽略-->
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>

这样列表表头(headData)和数据(tableData) 根据需要显示的变量动态获取展示。
过程中有个问题 – 使用scope.column.property可以获取属性,但是使用scope.column.prop就不行
官方文档是写的prop,因此不知道问题出在哪。。。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/gua222/article/details/106288673