用于登录或者注册页面
const rules = {
//TS
username: [
{required: true, message:'请输入用户名', tirgger:'blur'},
{min: 5, max: 10, message:'用户名必须是5-10位字符', tirgger:'blur'}
],
password:[
{required: true, message:'请输入密码', tirgger:'blur'},
{pattern:/^\S{6,15}$/,message:'密码必须是6-15位的非空字符',tirgger:'blur'}
],
repassword:[
{required: true, message:'请输入密码', tirgger:'blur'},
{pattern:/^\S{6,15}$/,message:'密码必须是6-15位的非空字符',tirgger:'blur'},
{
validator:(rule,value,callback) => {
//判断
if(value !== formModel.value.password){
callback(new Error('两次密码不一致'))
}else{
callback()
}
},
tirgger:'blur'
}
]
}