我想通过点击编辑或删除来获取那一行的数据,该怎么实现的呀,谢谢了
info是从后端获取的数据
<el-table-column>
//定义此行代码
<template slot-scope="scope">
<el-row>
<el-button type="primary">修改</el-button>
//下面这行就是删除按钮的点击事件
<el-button type="danger" @click="deleteById(scope.row)">删除</el-button>
</el-row>
</template>
</el-table-column>
拿到对应的 id 然后发送请求去删除对应的数据 然后再次请求数据刷新列表!大概是这么个思路
删除就是 对数组 的过滤 。可以用filter 过滤 点击事件 传一个id 然后
data是表格绑定的数据 id是删除 点击事件 传过来的
let arr=data.filter((item)=>{
return item.id!=id;
})
this.data=arr;