I have an errors object:
data() {
return {
...
errors: {
login: {
email: '',
password: '',
},
register: {
name: '',
email: '',
password: '',
password_confirmation: '',
},
}
}
},
How can I set the value of all items inside errors object to '' (just clear them)?
I can clear all items inside data object with
Object.assign(this.$data, this.$options.data.call(this));
But
Object.assign(this.$data.errors, this.$options.data.call(this));
or
Object.assign(this.$data.errors, {});
or
this.errors = ''
or
this.$set(this.$data.errors, '');
doesn't work.
Update 1
This one works for clearing errors.login:
Object.assign(this.$data.errors.login, this.$options.data.call(this));
I think I cann pass a variable to clear(obj) and use it
Object.assign(this.$data.errors.obj, this.$options.data.call(this));
but anyway looking how to clear all errors object.
Update 2
Object.assign(this.$data.errors.register, this.$options.data);
clears only email and password inside errors.register - can't get that logic.
loginandregisterobjects to be set to the empty string