[转]Vue element怎么获取table表格当前行数据和索引值

怎么拿表格当前行数据
平时我们在使用表格时通过template的slot-scope="scope",使用scope.row拿到当前行的数据

<el-table max-height="290" :data="userTableData" border style="width: 100%">
      <el-table-column label="名字">
            <template slot-scope="scope">
              {{scope.row.name}}
            </template>
      </el-table-column>
       <el-table-column label="年龄">
            <template slot-scope="{row}">
              {{row.age}}
            </template>
      </el-table-column>
</el-table>

怎么拿表格当前行索引值

<el-table max-height="290" :data="userTableData" border style="width: 100%">
      <el-table-column label="序号">
            <template slot-scope="scope">
                  {{scope.$index+1}} 
            </template>
      </el-table-column>
</el-table>

From: https://blog.csdn.net/meimeib/article/details/111075715

 

posted @ 2021-07-29 11:09  ec04  阅读(5458)  评论(0编辑  收藏  举报