el-table选框选中和整行选中

96 阅读1分钟
                  <el-table
                    ref="multipleTable"
                    :data="userList"
                    tooltip-effect="dark"
                    style="width: 100%"
                    @row-click="rowclick"
                    @select-all="clickAll"
                    @select="clickSelect"
                  >
                  
                  // 点击选择框
                clickSelect(select, row) {
                  if (this.currentId.indexOf(row.userId) == -1) {
                    this.currentId.push(row.userId);
                  } else {
                    let index = this.currentId.indexOf(row.userId);
                    this.currentId.splice(index, 1);
                  }
                },
                // 点击整行
                rowclick(row) {
                  if (this.currentId.indexOf(row.userId) == -1) {
                    this.currentId.push(row.userId);
                  } else {
                    let index = this.currentId.indexOf(row.userId);
                    this.currentId.splice(index, 1);
                  }
                },
                clickAll() {
                  if (this.isAll) {
                    this.currentId.splice(0, this.currentId.length);
                    this.isAll = false;
                  } else {
                    this.currentId.splice(0, this.currentId.length);
                    this.data.forEach(item => {
                      this.currentId.push(item.userId);
                    });
                    this.isAll = true;
                  }
},