<el-table ref="courseList" :data="courseList" row-key="id" @selection-change="handleCourseSelection">
//...
<el-table>
//方法
handleCourseSelection(selection) {
// console.log(selection);
if(selection.length > 2) {
this.$message.warning(`最多只能选择2个课程`);
let del_row = selection.pop()
this.$refs.courseList.toggleRowSelection(del_row, false)
} else {
this.selsectionCourse = selection
}
},
//在样式里面增加这个可以隐藏全选框
::v-deep .el-table__header-wrapper .el-checkbox {
// display: none;//设置不成功,页面卡顿
visibility: hidden;
}
网友评论