Vue elementUI 多选表格实现单选操作
发布时间
阅读量:
阅读量
<el-table :data="tableData" select="selectChoose" v-loading="loading" style="width: 100%" ref="multipleTable">
<el-table-column type="selection"></el-table-column>
</el-table>
//clearSelection:用于多选表格,清空用户的选择
//toggleRowSelection用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
selectchoose(selection,row){//当checkbox改变时触发
console.log( "row",row)
//当点击时selection会存放当前行数据
this.$refs.multipleTable.clearSelection();//先清空选中状态,selection值还在
if (selection.length === 0){//这里状态为勾选
return;
}
this.$refs.multipleTable.toggleRowSelection(row,true);//用于切换某行选中状态
}
全部评论 (0)
还没有任何评论哟~
