data() {
const equalToPassword = (rule, value, callback) => {
if (this.form.newPassword !== value) {
callback(new Error("新密码与确认密码不一致,请仔细核对"));
} else {
callback();
}
};
return {
form: {
oldPassword: "",
newPassword: "",
confirmPassword: "",
},
formRules: {
oldPassword: [
{ required: true, message: "请输入旧密码", trigger: "blur" },
{
pattern: /^\w+$/,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "change",
},
{
min: 6,
max: 20,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "blur",
},
],
newPassword: [
{ required: true, message: "请输入新密码", trigger: "blur" },
{
pattern: /^\w+$/,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "change",
},
{
min: 6,
max: 20,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "blur",
},
],
confirmPassword: [
{ required: true, message: "请输入确认密码", trigger: "blur" },
{
pattern: /^\w+$/,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "change",
},
{
min: 6,
max: 20,
message:
"密码只允许字母、数字与下划线的组合,长度为6-20,请仔细核对",
trigger: "blur",
},
{ required: true, validator: equalToPassword, trigger: "blur" },
],
}
};
},