Element table 表格实现单选

创建表格 添加 @select-all=“selectAll” @select=“selectAnalysis” ref=“multipleTable”

<el-table @select-all="selectAll" ref="multipleTable" @select="selectAnalysis" v-loading="loadingAnalysis" style="margin-top: 10px"  height="350px" :data="analysisData" border stripe size="small" :header-cell-style="{background:'#ECF5FF',color:'#606266',fontWeight:'bold',align:'center'}" highlight-current-row>
  <el-table-column fixed type="selection" width="55"></el-table-column>
</el-table>

实现单选

selectAnalysis(selection, row) {
    
    
  if (selection.length > 1) {
    
    
    let del_row = selection.shift();
    this.$refs.multipleTable.toggleRowSelection(del_row, false); // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
  }
},

取消取选

selectAll() {
    
    
	this.$refs.multipleTable.clearSelection()
},

猜你喜欢

转载自blog.csdn.net/weixin_44640323/article/details/120510400
今日推荐