1、删除
<el-table-column label="状态">
// 获取当前行的所有数据
<template slot-scope="scope">
// 在这里添加点击事件方法 使用上边获取当前行所有数据 传入id值
<el-button type="danger" icon="el-icon-delete" circle @click="delInfo(scope.row.id)"></el-button>
</template>
</el-table-column>
2、点击事件方法
async delInfo (id) {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
// 调接口 赋值给 res
const { data: res } = await this.$ajax.delete('users/' + id)
// 判断状态 返回成功或失败
if (res.meta.status !== 200) return this.$message.error('删除失败')
this.$message.success('删除成功')
// 重新渲染页面
this.getUserList()
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
}