【发布时间】:2022-09-28 02:33:03
【问题描述】:
我正在创建一个谜语游戏。问题首先在隐藏的 div 中显示解决方案。如何获得在特定谜语上单击的目标并仅在另一个 div 中显示该谜语的解决方案。
问题在一个对象中:
const stories = [
{ id: 1, title: first riddle, solution: this is the first solution },
{ id: 2, title: second riddle, solution: this is the second solution }];
我在 Card 组件中渲染了 stories 对象,并通过它们进行了映射:
{ stories.map((story, index) =>
<Story key={index} id={story.id} title={story.title} desc={story.desc} grade={story.grade} /> )}
我在 Card 组件上与onClick={this.handleClick} 一起尝试了一些东西,但我无法弄清楚如何展示解决方案。
标签: javascript reactjs components