通过数据的下标删除对应数据,表格点击删除的时候插槽scope中获取不到$index:
<table-column title="操作" fixed="right" width="80px" >
<template slot-scope="scope">
<el-button type="text" @click="remove(scope.$index)" >删除</el-button>
</template>
</table-column>
method:
remove(index){
console.log(index)
this.tableData.splice(index,1)
}
插槽传参改用scope.$rowIndex:
<template slot-scope="scope">
<el-button type="text" @click="remove(scope.$rowIndex)" >删除</el-button>
</template>
发表回复