// 检验邮箱
var checkEmail = (rule, value, cb) => {
const regEmail = /^\w+@\w+(.\w+)+/
if (regMobile.test(value)) {
return cb()
}
// 返回错误提示
cb(new Error('请输入合法的手机号码'))
}
addRules: {
email: [
{ required: true, message: '请输入邮箱', trigger: 'blur' },
{ validator: checkEmail, message: '邮箱格式不正确,请重新输入', trigger: 'blur' }
],
mobile: [
{ required: true, message: '请输入手机', trigger: 'blur' },
{ validator: checkMobile, message: '手机格式不正确,请重新输入', trigger: 'blur' }
]
},
网友评论