带勾选的el-table有时候需要设置不可被勾选,遇到这种需求时,可采用以下方式
<el-table :data="tableVal" style="margin-bottom: 10px;" border height="65vh" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" ref="multipleTable" element-loading-background="rgba(0, 0, 0, 0.7)" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" :selectable="checkboxInit"></el-table-column>
</el-table>
在勾选栏设置 :selectable=“checkboxInit”
其中checkboxInit带有两个默认参数,一个是循环出来的当前对象,一个是当前下标
checkboxInit(row,index){
if(row.usedRemark){
return 1
}else{
return 0
}
},
当符合某个条件时,可被勾选,不符合的时候,返回0,不可被勾选,复选框会是置灰状态