头图

本篇文章为日常功能点,在日常开发中经常碰到这个需求
话不多说直接上代码:

<el-table :border="true" :data="tableData">
   <el-table-column type="selection" :selectable="selectEnable" />
</el-table>
ids:[], // 勾选的id数组

selectEnable(row) {
  // 如果当前列的id在id数组中存在,则返回false禁止勾选
  return !this.ids.includes(row.id)
},

你只需要给table上添加selectable方法,然后在该方法内判断勾选的id是否存在即可


兔子先森
399 声望17 粉丝

致力于新技术的推广与优秀技术的普及。