elementUI中messageBox自定义展示内容

前提:使用了elementui中提交内容的MessageBox弹窗,但需要在弹窗上加上一个记住邮箱的元素,且需要与后台对接

原来代码如下:

this.$prompt('请输入邮箱', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
          inputErrorMessage: '邮箱格式不正确'
        }).then(({ value }) => {
          this.$message({
            type: 'success',
            message: '你的邮箱是: ' + value
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          });       
        });

拿到需求时我都不知道要怎么插元素进去,看了文档可以在message属性定义,于是就看了一些帖子,get到了新知识

代码如下:

    downloadFile(file, event) {
      console.log(file, event);
      const h = this.$createElement;
      var that = this
      event.stopPropagation();//阻止事件冒泡
      this.$prompt("", "提示", {
        message: h("p", null, [
          h("span", null, "请输入接收文件邮箱 "),
          h(
            "el-checkbox",
            { style: "width:5rem", on: { change: that.getCheck } },
            "记住邮箱"
          ),
        ]),
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern:
          /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
        inputErrorMessage: "邮箱格式不正确",
      })
        .then(({ value }) => {
          this.$message({
            type: "success",
            message: "文件正快马加鞭到您的邮箱,预计1~3分钟内抵达",
          });
        })
        .catch(() => {});
    },
    getCheck(val) {
      this.isCkeckEmail = val;
    },

效果如图:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值