element-ui的prompt如何在输入内容以后点击了确定事关闭弹窗

 cancelAudit(){

       var _this=this;

      this.$prompt("撤销审核的原因:", "提示", {

        confirmButtonText: "确定",

        cancelButtonText: "取消",

        inputValidator: (value) => {  

             if(!value) {//对输入内容校验

                  return '撤销审核的原因不能为空!';

             }

         },

        beforeClose: function (action, instance,done) {

             if(action === 'confirm') {    

                this.confirmButtonText="提交中..."   

                 cancelaudit({auditremark:instance.inputValue}).then(res=>{//instance.inputValue输入的值

                    if (res.code === 1) {

                          _this.$message(res.msg, { type: "success" });

                          _this.init();//访问当前页面的其他接口。要用_this

                         done();

                  }else{

                      _this.$message(res.msg, { type: "error" });

                      $(instance.$el).find('input').focus();

                  }

                })

             }else{

                done();

             }

        }

      }).catch(() => {}); 

    },

你可能感兴趣的:(element-ui)