当前位置:   article > 正文

el-table修改原有数据如何获取当前行号并进行赋值_el-table获取行号

el-table获取行号

1.table序号中的prop名称与数据库中字段ID以示区分,如图所示:

2.通过:row-class-name="tableRowClassName"方法进行序号的掩饰与显示,如图所示:

  1. <el-table
  2. :row-class-name="tableRowClassName"
  3. border
  4. :data="tableData"
  5. style="width: 100%"
  6. height="300"
  7. row-key="id"
  8. >
  9. tableRowClassName({row, rowIndex}) {
  10. row.tableId = rowIndex+1;
  11. },

3.通过绑定方法进行当前行数据赋值操作,如图所示:

  1. <el-table-column prop="xm" label="作者姓名">
  2. <template slot-scope="scope">
  3. <el-input v-if="scope.row.lx != '1'" v-model="scope.row.xm" placeholder="作者姓名" clearable>
  4. </el-input>
  5. <el-autocomplete
  6. v-if="scope.row.lx == '1'"
  7. v-model="scope.row.xm"
  8. :fetch-suggestions="querySearchAsync"
  9. placeholder="请输入内容"
  10. @select="changeInfo($event,scope.row.index,scope.row)">
  11. <template slot-scope="{ item }">
  12. <div>{{ item.label }}</div>
  13. </template>
  14. </el-autocomplete>
  15. </template>
  16. </el-table-column>
  17. //赋值
  18. changeInfo(item,index,row){
  19. console.log(index,row,'===============================')
  20. this.tableData[row.tableId-1].xm = item.xm;
  21. this.tableData[row.tableId-1].gzbmmc = item.dwh;
  22. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/100976?site
推荐阅读
相关标签
  

闽ICP备14008679号