【发布时间】:2021-05-16 09:51:48
【问题描述】:
我无法让 Vuelidate sameAs 验证器正常工作。似乎 sameAs 验证器无法读取 this.password.new 因为根据我的调试, this 在 sameAs 函数中未定义。可能我做错了什么,但我无法找出问题所在。所有其他验证都运行良好。
export default {
name: 'login',
setup() {
return {
v$: useVuelidate()
}
},
data : function() {
return {
name : "",
email : "",
password : {
new : "",
newRepeated : ""
}
}
},
validations: {
name: {
required,
minLength: minLength(3)
},
email: {
required,
email
},
password: {
new : {
required,
strongPassword(password) {
return (
/[a-z]/.test(password) && //checks for a-z
/[0-9]/.test(password) && //checks for 0-9
/\W|_/.test(password) && //checks for special char
password.length >= 10
);
}
},
newRepeated : {
sameAs : sameAs(function() {return this.password.new})
}
}
},
methods: {
【问题讨论】:
标签: javascript ionic-framework vue-component vuejs3 vuelidate