0

我在地图中显示这 2 个循环时遇到问题。我使用此地图进行显示,但似乎无法显示两个循环。

我可以只在一个循环内显示它们吗?像循环内循环?在这里需要帮助 tia

Choices Data

{testQuestionData.map(({choices}) => (
   <div>{choices.map((tchoices)=>
      <div>
         {tchoices.testChoices}
      </div>
        )}
   </div>
))} 

Question Data

{testQuestionData.map(td=>(
  <div className="col-md-12">
     {td.question.testQuestion}
         <label>Choices: {td.choicesDisplay}</label>
   </div>
))}

{
  "question": {
    "testQuestion": "Earth is flat?",
  },
  "choices": [
    {
      "testChoices": "true",
      "
    }
   {
      "testChoices": "false",
      "
    }
  ]
}
4

1 回答 1

0

您的数据格式错误。"您在测试后有一个随机选择,而,在选择之间没有。

您的数据应如下所示

{
    "question": {
      "testQuestion": "Earth is flat?",
    },
    "choices": [
      {
        "testChoices": "true",        
      },
     {
        "testChoices": "false",        
      }
    ]
  }
于 2020-05-05T16:47:28.447 回答