element ui表格实现单选 但是单选取消会报错

1.在el-table中添加两个事件

 @selection-change="handleSelectionChange"
 @current-change="choosperssionChange"
  ref="Table"

 2.然后在methods定义两个方法

  
  // 点击表格中复选框拿到哪一行想要的数据
    handleSelectionChange(val) {
      if (val.length > 1) {
        this.$refs.Table.clearSelection();
        this.$refs.Table.toggleRowSelection(val.pop());
      } else{
//拿到想要的id什么的
} }, // 切换到某一行的状态 choosperssionChange(val) { this.$refs.Table.toggleRowSelection(val); },

3.这是我遇到的错误,因为我点击复选框,在点击一次会报错,以下是报错信息

 

posted @ 2020-07-24 18:00  恒哥的技术分享  阅读(679)  评论(0)    收藏  举报