要保证callback()只有一个出口
rules:{ newPassword: [{validator:(rule,newPassword,callback)=>{ var all = false if(newPassword == ‘‘){ callback(new Error("请输入密码")); }else{ var str = "" for(var i=0;i<newPassword.length;i++){ str = newPassword.charCodeAt(i) if(str > 65280 && str < 65375 || str == 12288){ all = true } } if(all == true){ callback(new Error("请输入半角字符")); }else{ callback() } } }, trigger:‘blur‘}] }
时间: 2024-10-08 11:52:01