首页 > 其他分享 >VUE3 elment-ui el-tabel遍历实现表格的自定义列【KEY值为列名】

VUE3 elment-ui el-tabel遍历实现表格的自定义列【KEY值为列名】

时间:2022-11-16 15:34:39浏览次数:51  
标签:el 自定义 tabel param5 115.2 param4 param3 param2 param1

<template>
    <div>
        <el-table :data="resultTable" border ref="multipleTable" tooltip-effect="light" size="mini">
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column v-for="(key,index) in Object.keys(resultTable[0])" :key="Math.random(index)" :label="key" :prop="key" align="center" show-overflow-tooltip>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
export default {
    data(){
        return{
            resultTable:[
                {
                    "param1":5,
                    "param2":31,
                    "param3":115,
                    "param4":115.1,
                    "param5":115.2
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                },{
                    "param1":5.1,
                    "param2":31.1,
                    "param3":115.1,
                    "param4":115.2,
                    "param5":115.3
                }
            ]
        }
    },
}
</script>

 

标签:el,自定义,tabel,param5,115.2,param4,param3,param2,param1
From: https://www.cnblogs.com/mentu21/p/16896046.html

相关文章