<template>
    <el-table @selection-change="handleSelectionChange" :row-key="getRowKeys">
        <!--type必须是selection的一列设置reserve-selection属性-->
      <el-table-column type="selection" :reserve-selection="true" width="40" align="center"></el-table-column>
      <el-table-column props="name" align="center"></el-table-column>
    </el-table>
</template>

<script>
     export default {
         data: {
             selection:[{name: '张三', id: 1}, {name: '李四', id: 2}]
         },
         methods: {
             handleSelectionChange (val) {
                 this.selection = val;
             },
             getRowKeys (row) {
                 return row.id; // id为列表数据的唯一标识
             }
         }
     }
</script>

 

相关文章:

  • 2022-12-23
  • 2021-07-14
  • 2022-02-01
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案