<el-table :data="tableData6" :row-key="getRowKey" ref="buyerTable" height="300" @selection-change="handleSelectionChange" border style="width: 100%"> <el-table-column type="selection" :reserve-selection="true" width="55"> </el-table-column> <el-table-column prop="id" label="ID" width="180"> </el-table-column> <el-table-column prop="name" label="姓名"> </el-table-column> <el-table-column prop="amount1" sortable label="數值 1"> </el-table-column> <el-table-column prop="amount2" sortable label="數值 2"> </el-table-column> <el-table-column prop="amount3" sortable label="數值 3"> </el-table-column> </el-table> <el-pagination @size-change="handleBuyerSizeChange" @current-change="handleBuyerCurrentChange" :current-page="currentBuyerPage" :page-sizes="[5, 10, 15, 20]" :page-size="buyerPageSize" layout="total, sizes, prev, pager, next, jumper" :total="buyerTotalCount"> </el-pagination>
js代碼:this
methods: { // 保存選中的數據id,row-key就是要指定一個key標識這一行的數據 getRowKey (row) { return row.id }, // 列表選擇,val選中的表格行數據 handleSelectionChange (val) { console.log(val) }, // 清空選擇的值 clearSelect () { this.$refs.buyerTable.clearSelection() } }