<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>