element的el-table中使用span-method的一个问题

<el-table :data="item" :span-method="objectSpanMethod" :show-header="index===0 ? true :false" border v-for="(item,index) in optimizationList" :key="index">

</el-table>

我想用table的合并行,但是这个表格是多个循环出来的,我怎么在span-method的objectSpanMethod函数中得到是第几个表格的

阅读 6.1k
1 个回答

最近也遇到这个问题,提供一个解决思路吧。objectSpanMethod({ row, column, rowIndex, columnIndex })中每次会获取row整条数据,可以每一个table数据中定义一个唯一的tableKey,table中每一条数据都要加这个tableKey,然后在objectSpanMethod({ row, column, rowIndex, columnIndex })通过row.tableKey区分匹配table

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进