element-plus里的el-table获取表格数据索引下标
·
首先要在表格里添加 :row-class-name=“rowClassName”
<el-table
:data="tableData"
ref="multipleTable"
:row-class-name="rowClassName"
border
>
<el-table-column prop="name4" label="所属部门"></el-table-column>
<el-table-column label="操作">
<template #default="scope">
<el-button type="text" size="medium" @click="update(scope.row)">修改</el-button>
</template>
</el-table-column>
</el-table>
export default {
data(){
return{
tableData:[],
}
},
methods:{
rowClassName({row, rowIndex}) {
//把每一行的索引放进row
row.index = rowIndex;
},
update(id,row){
this.$nextTick(() => {
setTimeout(()=>{
console.log(row.index);
this.addyg=true
this.tianjia=this.tableData[row.index]
},100)
})
},
}
}
更多推荐
所有评论(0)