I am using VueJs and will be using logic to bring a user to one of three components based on the outcome of an if statement. The property being brought into this child component from its parent is userResultData. The idea is that the data in this it passes the properties of the userResultData array and move into more components once I can get the console to show things are processing the way they should. Inside userResultData, it has two more arrays, employees or managers. The user can have values in employees or in managers or both. If it there are only values in the employees array, one action will result. The same applies for managers. If both have a value then it's the final condition since it has both.
However, I am getting an interesting error, so clearly something isn't right. I'm relatively new to JavaScript and this framework, so if anyone wouldn't mind a simple explanation on what I can fix, it's much appreciated.
Here is what I have:
import EmployeeAndManagerUser from '../Organization/EmployeeAndManagerComponent.vue';
import EmployeeUser from '../Organization/EmployeeComponent.vue';
import ManagerUser from '../Organization/ManagerComponent.vue';
export default {
props: ['userResultData'],
components: {
ManagerUser,
EmployeeUser,
EmployeeAndManagerUser
},
data() {
return {
userResultArrayData: null,
managerUser: null,
employeeUser: null,
employeeAndManagerUser: null
}
},
methods: {
evaluateTypeOfUser(){
if (Object.keys(this.managers) === 0 && Object.keys(this.employees).length !== 0) {
console.log('result matched with employee ');
}
else if (Object.keys(this.managers) !== 0 && Object.keys(this.employees).length === 0) {
console.log('result matched with manager ');
}
else {
console.log('result is both employee and manager');
}
}
}
}
Error: Uncaught TypeError: Cannot convert undefined or null to object at Function.keys () at VueComponent.evaluateTypeOfContact (app.js:38281)
Aucun commentaire:
Enregistrer un commentaire