element-ui按钮点击显示是否执行

现有需求点击按钮,需要确认是否执行,看了下element-ui的官网方法,地址如下

https://element.eleme.cn/#/zh-CN/component/message-box
在这里插入图片描述

<template>
  <el-button type="text" @click="open">点击打开 Message Box</el-button>
</template>

<script>
  export default {
    methods: {
      open() {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      }
    }
  }
</script>

然后根据这做法写出自己的前后端交互的方法,第一次用这组件用的不怎么好,也不知道怎么写,就照猫画虎的写了一下,应该还能精简
在这里插入图片描述

forceUpdateDevice(){
                    this.$confirm('此操作将强制重置设备, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        Fetch.delete("${request.contextPath }/member/forceUpdateDevice", {
                            id: memberId
                        }).then(result => {
                            if (!result){
                                this.$message({
                                    type: 'warning',
                                    message: '重置失败!'
                                });
                            }else {
                                this.$message({
                                    type: 'success',
                                    message: '重置成功!'
                                });
                            }

                        }).catch().finally();
                    }).catch(() => {
                            this.$message({
                                type: 'info',
                                message: '已取消强制重置设备'
                            });
                    });
                },

感觉很冗杂,正在想办法精简。但是效果是出来了
在这里插入图片描述
后台也成功的交互到了
在这里插入图片描述

顺便记录下进这个页面之前的layui是否显示该标签的用法或者说是语法,反正我看着是挺反感的
d就是该行的数据,是个形参

<script type="text/html" id="updateDeviceTpl">
    {{# if(d.unbind == true){ }}
    <input type="checkbox" name="updateDevice" value="{{d.id}}" title="解绑" lay-filter="updateDevice" {{d.unbind== true ? 'checked':'' }}></input>
    {{# }if(d.unbind == false){ }}
    <input type="checkbox" name="updateDevice" value="{{d.id}}" title="解绑" lay-filter="updateDevice" {{d.unbind== true ? 'checked':'' }} disabled></input>
    {{#  } }}
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值