美文网首页
element-ui 单元格点击事件,行点击+单元格点击,获取某

element-ui 单元格点击事件,行点击+单元格点击,获取某

作者: 残_忆 | 来源:发表于2019-10-09 15:28 被阅读0次
    <el-table :data="tableData" stripe  @cell-click="addSubAccount" :row-class-name="tableRowClassName">
         <el-table-column prop="installer" label="主子账号">
         </el-table-column>
    
     </el-table>
    
      
      //下面是利用给表格添加className,添加index
      tableRowClassName ({row, rowIndex}) {
        //把每一行的索引放进row
        // console.log(row,rowIndex)
        row.index = rowIndex;  //拿到的索引赋值给row的index,在这个表格中能拿到row的里面都会包含index
        return 'row-remarks'  //className(类名)
      },
       addSubAccount(row){ //获取焦点弹出关联多个子账号
            console.log(row.index)
          },
    //如果需要区分那一数列的才能触发需要判断下prop的值
    addSubAccount(row,column){ //获取焦点弹出关联多个子账号
        console.log(row.index)  //获取下标
       console.log(column.property ) //获取判断条件
        if(column.property == 'prop的值'){  //prop的值是自己设置的,注意别重复设置同一个值
    
        }
      },
      //如果表格既有行点击,又有单元格点击,在行点击事件里判断prop,等不等于你行点击的prop,如果等于直接return false  跳出
    

    相关文章

      网友评论

          本文标题:element-ui 单元格点击事件,行点击+单元格点击,获取某

          本文链接:https://www.haomeiwen.com/subject/wjoluctx.html