如何解决未捕获的类型错误:无法读取未定义的属性“forEach”//检测未定义
我做错了什么? 需要在这里检测问题。
function showQuestion(question) {
questionElement.innerText = question.question
question.answers.forEach(answer => {
const button = document.createElement('button')
button.innerText = answer.text
button.classList.add('btn')
if (answer.correct) {
button.dataset.correct = answer.correct
}
button.addEventListener('click',selectAnswer)
answerButtonsElement.appendChild(button)
})
}
解决方法
问题已解决 拼写错误的答案对象并且正在循环正确拼写答案.....
上帝.....Javascript!!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。