<template>
  <div>
    <el-table :data="tableData">
      <el-table-column
        v-for="column in columns"
        :key="column.prop"
        :prop="column.prop"
        :label="column.label"
        :sortable="column.sortable"
      ></el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [
        { id: 1, name: 'John', age: 20 },
        { id: 2, name: 'Jane', age: 25 },
        { id: 3, name: 'Bob', age: 30 }
      ],
      columns: [
        { prop: 'id', label: 'ID', sortable: true },
        { prop: 'name', label: 'Name', sortable: false },
        { prop: 'age', label: 'Age', sortable: true }
      ]
    }
  }
}
</script>

原文地址: https://www.cveoy.top/t/topic/qevH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录