首先需要在表格里拿到下标
借用 row-class-name 属性来给表格附上 index
表格上添加 :row-class-name=“getRow”
<el-table :data="tableList" :row-class-name="getRow">
<el-table>
getRow({row,rowIndex}) {
row.index = rowIndex;
},
使用:ref="name${index}
" ,为每一项动态添加ref
比如:
<el-table-column property="consumer_offset" label="consumerOffset">
<template slot-scope="scope">
<p
:ref="`inputbox${scope.row.index}`"
:contenteditable="scope.row.Editsave"
style="border:none;background-color:transparent"
>{{scope.row.consumer_offset}}</p>
</template>
</el-table-column>
划重点 :ref="
inputbox${scope.row.index}"
取值方法:this.$refs[
inputbox${row.index}].innerText
顺利拿到想要的值