element plus与element ui 多选表格判断某行是否选中 电脑版发表于:2023/9/1 14:45 #### element plus 多选表格判断每行是否选中 ``` @select="selectRow" const selectRow = (selection: any, row: any) => { console.log(selection) console.log(row) // true就是选中,0或者false是取消选中。当前选中的这行包含在选中里边就说明当前这行是选中嘛,否者就是没有选中的状态 let selected = selection.length && selection.indexOf(row) !== -1 console.log(selected) } ``` ### element ui 中的table判断某行是否选中 ``` <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @select='onSelect' @selection-change="handleSelectionChange"> <el-table-column type="selection" </el-table-column> <el-table-column label="日期" width="120"> <template slot-scope="scope">{{ scope.row.date }}</template> </el-table-column> </el-table> methods: { handleSelectionChange(val) { this.multipleSelection = val; }, onSelect(rows, row) { let selected = rows.length && rows.indexOf(row) !== -1 console.log(selected) // true就是选中,0或者false是取消选中 } } ```