Mint-UI组件 MessageBox为prompt 添加判断条件

Mint-UI 的Message Box 是prompt类型时,可以添加正则判断或者function判断条件。具体可以查看Mint-UI源码。

添加正则判断条件:

MessageBox({
    $type:'prompt',
    title:'输入验证码',
    message:'请填写您收到的验证码',
    closeOnClickModal:false,   //点击model背景层不关闭MessageBox
    showCancelButton:false,   //不显示取消按钮
    inputValidator:/^[a-zA-Z0-9]{6}$/,    //正则条件
    inputErrorMessage:'请输入正确的验证码',
    showInput:true
}).then(({ value, action }) => {
    /* value 为填写的值,进行下一步操作*/
    console.log(value);
});

添加function判断条件

MessageBox({
    $type:'prompt',
    title:'输入验证码',
    message:'请填写您收到的验证码',
    closeOnClickModal:false,    //点击model背景层不关闭MessageBox
    showCancelButton:false,     //不显示取消按钮
    inputValidator:function(v){return /^[a-zA-Z0-9]{6}$/.test(v);},  //function可以用来写更复杂的判断条件,返回布尔值
    inputErrorMessage:'请输入正确的验证码',
    showInput:true
}).then(({ value, action }) => {
    /* value 为填写的值,进行下一步操作 */
    console.log(value);
});

猜你喜欢

转载自blog.csdn.net/sym134/article/details/86165766