【问题标题】:Uncaught TypeError: Cannot read property 'forEach' of undefined// detect undefined未捕获的类型错误:无法读取未定义的属性“forEach”//检测未定义
【发布时间】:2021-05-10 22:59:00
【问题描述】:

我做错了什么? 需要在这里检测问题。

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 foreach undefined typeerror


    【解决方案1】:

    问题已解决 拼写错误的答案对象并且正在循环正确拼写答案.....

    上帝.....Javascript!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-24
      • 1970-01-01
      • 2015-01-06
      • 2022-08-15
      • 1970-01-01
      • 2018-10-29
      • 2017-07-26
      相关资源
      最近更新 更多