2***@qq.com
2***@qq.com
  • 发布:2017-07-20 08:47
  • 更新:2017-07-20 15:12
  • 阅读:4852

mui.confirm 为什么return false 弹窗还是会关闭

分类:MUI
       mui.confirm('<input type="text" id="email" /><span id="error">&nbsp</span>', '文件将发送到以下邮箱', null, function(event) {  
        var index = event.index;  
        var szReg=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;   
        if(index === 1) {  
        if(szReg.test(pwd)=='') {  
             proj.scan.sendEmail(id,pwd);  
        }else{  
            return false;  
          }  

        }  
      },'div');
2017-07-20 08:47 负责人:无 分享
已邀请:
chender

chender - 与人为善

如果是只要点了按钮都会关闭的话,你可以把return false 换成再次调用mui.confirm

破晓残雪

破晓残雪

由于当前版本mui,点击dialog中的按钮均会关闭dialog,所以需要对dialog按钮的默认行为进行修改
mui.confirm('<input type="password" id="test" />', 'Hello MUI', null, function(event) {
var index = event.index;
if(index === 1) {
var pwd = document.getElementById('test').value;
// 验证失败返回false
return false;
}
},'div');

Neil_HL

Neil_HL

要么是你mui版本过低,要么就是正则匹配有问题,你尝试下面一段代码

var num = 0;  
mui.confirm('<input type="text" id="email" />', '文件将发送到以下邮箱', null, function(event) {  
    var index = event.index;  
    if(index === 1) {  
        if(num === 0){  
            num += 1;  
            console.log('没关闭');  
            return false;  
        }else{  
            console.log('关闭了');  
        }  
    }  
}, 'div');
  • 1***@qq.com

    你好,return false;确认框还是关闭了,mui版本是Mui v3.7.2 (http://dev.dcloud.net.cn/mui)

    代码:

    mui.confirm(remarks, '发 现 新 版 本', btnArray, function(e) {

    if(e.index == -1){

    return false;

    }

    if(e.index == 0){//同步

    downWgt(updateUrl);

    }else {//取消

    isCloseUpdate = true;

    }

    return true;

    });

    2019-06-13 16:07

  • 洛安奕然

    回复 1***@qq.com: 一样不行,返回false还是关闭

    2019-06-26 14:51

2***@qq.com

2***@qq.com (作者)

找到原因了,mui.js版本过低,3.3以后的版本才可以用return false阻止

  • 1***@qq.com

    我是mui 3.7 但是也不行

    2019-06-13 15:52

该问题目前已经被锁定, 无法添加新回复