【发布时间】:2020-12-18 18:36:29
【问题描述】:
我是新来的反应,在另一个 .map 中做一个 .map 不是很舒服。
我现在已经完成了,结果就是我想要的,除了一件事。
我想用<hr /> 分隔两个 .maps 之间的结果,但我不知道该放在哪里。
我尝试了不同的地方,比如在第一个 .map 的大括号之后,但它从来没有奏效。
有人可以帮帮我吗?
我的代码:
{data.map((responses) => {
return responses.answers.map((element) => {
return (
<article>
<div className="question">
<div
className="square"
>
<span>{element.type === "texte" ? "1" : "2"}</span>
<img src={Minus} alt="" />
<img
src={element.type === "texte" ? FileWhite : StarWhite}
alt=""
/>
</div>
<div>{element.question}</div>
</div>
{element.type === "texte" ? (
<div className="answerText">{element.answer}</div>
) : (
<div className="answerNote">
<div className="square">
<input type="radio" id="note1" name="note" value="1" />
<label htmlFor="note1">1</label>
</div>
<div className="square">
<input type="radio" id="note2" name="note" value="2" />
<label htmlFor="note2">2</label>
</div>
<div className="square">
<input type="radio" id="note3" name="note" value="3" />
<label htmlFor="note3">3</label>
</div>
<div className="square">
<input type="radio" id="note4" name="note" value="4" />
<label htmlFor="note4">4</label>
</div>
<div className="square">
<input type="radio" id="note5" name="note" value="5" />
<label htmlFor="note5">5</label>
</div>
</div>
)}
</article>
);
});
})}
</div>
【问题讨论】:
标签: reactjs dictionary