I have a Vue form that is set up like this:
new Vue({
el: '#login-container',
data: {
firstname: '',
lastname: '',
email: '',
birthday: '',
signupEmail: '',
password: '',
signupPassword: '',
confirm: '',
error: ''
},
methods: {
login(){
CH.INSTANCE.Services.Login(this.email, this.password, login_onComplete, login_onCancel);
function login_onComplete(aUser)
{
window.location.href = '/';
}
function login_onCancel(aMessage)
{
this.error = aMessage ;
}
},
signup(){
CH.INSTANCE.Services.CreateAccount(this.firstname,this.lastname,this.signupEmail, this.signupPassword,'83835', 'male',this.birthday,':checked',onRegister_onComplete,onRegister_onError);
function onRegister_onComplete(aUser)
{
window.location.href = '/';
}
function onRegister_onError(aMessage)
{
this.error = aMessage;
}
}
}
})
The form works well except for the this.error = aMessage ;
part.
When something goes wrong, the aMessage
should be displayed in {{error}} on my form, but it doesn't seem to work.
If I manually set this.error = 'test' ;
outside of the if
statement at the beginning of the login()
method, it does work when called.
Similarly, if I just use console.log(aMessage)
within the if
statement, it also works fine.
I am puzzled as to why setting this.error
directly does not seem to work as expected.