Closed lemonzeng closed 1 month ago
{questions.map((question, index) => ( <div key={index} className="mx-3 mb-4 border border-secondary"> <div className="p-3 border-bottom border-secondary" style={{ backgroundColor: "#f5f5f5" }} > <div className="float-end font-color-secondary"> {answer.answers[index].score}/ {question.points} pts </div> <div className="fw-bold">Question {index + 1}</div> </div> <div> <div id="question-description" className="p-3 my-3"> {question.question} </div> <div> <AnswerByType question={question} answer={answer.answers[index]} showCorrect={showCorrect} /> </div> </div> </div> ))}
原因: answer.answers.length != question.length 导致answer.answers[index]为undefined
answer.answers[index]
修改测试数据导致的
原因: answer.answers.length != question.length 导致
answer.answers[index]
为undefined