当前位置: 移动技术网 > 移动技术>移动开发>Android > elementui e-button删除,查到本条数据的id后向后台传参并进行删除

elementui e-button删除,查到本条数据的id后向后台传参并进行删除

2020年07月17日  | 移动技术网移动技术  | 我要评论

html代码
scope.row.id传递本条数据的id的参数

<template slot-scope="scope">
<el-button type="text" @click="open(scope.row.id)" size="small" >删除</el-button>
</template>

js代码

        open(e) {
            console.log(e)//e是html页面中传递过来本条数据的id
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                let that=this;//改变this指向
                axios.get('http://localhost:8080/deleteByid',{
                    params : {
                       id:e
                    }
                }).then(function (res) {
                //判断success是否为true
                    if(res.succeed===false){
                        that.$message({
                            type: 'info',
                            message: '删除失败!'
                        });
                    }else {
                        that.$message({
                            type: 'success',
                            message: '删除成功!'
                        });
                        that.getTabelInfo()//删除成功后,刷新当前页面,重新渲染数据
                    }

                }).catch(function (reason) {
                    console.log(reason);
                })
        }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
        });
        }

删除成功啦!

本文地址:https://blog.csdn.net/weixin_42699659/article/details/107381680

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网