需求:想给el-table渲染出的某列td增加id属性,id的值为 id=“xxx-{{index}}” index
是当前行的索引
怎么解决. . .
下面是我的尝试:
<el-table-column
:id="index"
prop="created_at"
label="日期"
sortable
:formatter="formatterDate"
width="180"
align="center">
</el-table-column>
失败,index
未定义
可以嵌入一个
<template>
设置属性slot-scope="scope"
,索引值就可以这样取到scope.$index
如下示例