I've some component in VueJs that looks like this:
export default {
name: 'RecruitForm',
data() {
return {
form: {
child: {},
mother: {},
father: {}
},
isSubmiting: false,
isValid: true
}
},
methods: {
submit: () => {
this.isSubmiting = true;
this.isValid = true;
let validateObject = (obj) => {
var keys = Object.keys(obj);
if(keys.length === 0){
return false;
}
for (var key in keys) {
if (!this.form[key])
isValid = false;
}
}
validateObject(this.form.child);
validateObject(this.form.mother);
validateObject(this.form.father);
}
}
}
When the validateObject method is fired and I'm trying to access nested properties of form object I get can not read property 'child' of undefined
error. While debbuging in console I can see that the form is not regular object but {__ob__: Observer}