case1
Error code
quizList[index] = currentQuiz;
quizList[index].learningItem = item;
Error content
Cannot read properties of undefined (reading 'learningItem')
Error reporting reason
currentQuiz object may be undefined, if you add the property learningItem to the undefined object quizList[index] dynamically, it will cause the error “cannot set property xxx of undefined”.
Solution:
quizList[index] = currentQuiz == undefined ?{} : currentQuiz;
quizList[index].learningItem = item;
Just judge whether the quizlist [index] is undefined
case2
Error code
quiz.finishedstudent.forEach(item => {
if (item.score < 80) {
errorNum++;
}
})
Error content
Cannot read properties of undefined (reading 'forEach')
Solution:
if (quiz.finishedstudent != undefined) {
quiz.finishedstudent.forEach(item => {
if (item.score < 80) {
errorNum++;
}
})
}
Read More:
- Uni-app Error when assigning a value to a component: [system] TypeError: Cannot read property ‘name‘ of undefined
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Solved] react Chrome Browser Error: Uncaught TypeError: Cannot read properties of undefined (reading ‘forEach‘)
- The body of a for-in should be wrapped in an if statement to filter unwanted properties from the pro
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- [Solved] Element form method Error: TypeError: Cannot read properties of undefined (reading ‘resetFields’)
- Vue cannot read property ‘xxx’ of undefined solutions
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- Javascript SecurityError: Failed to read the’localStorage’ property from’Window’: Access is denied for this document.
- [Solved] Uni.createintersectionobserver Error: Uncaught TypeError: Cannot read property ‘bottom’ of null
- [Solved] Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘resetFields‘)“
- [Vue warn]: Error in callback for watcher “value“ (How to Solve)
- [Solved] Cannot read property ‘setCheckedKeys‘ of undefined“
- [Solved] electron Error: Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
- Cannot read property ‘isFile‘ of undefined [How to Solve]
- [Solved] Cannot read properties of undefined (reading ‘propsData‘)“
- [Solved] JS Error: Uncaught TypeError: Cannot set properties of null (setting ‘innerHTML‘)
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined