【发布时间】:2021-04-07 22:14:47
【问题描述】:
我有一个 json 格式的数据,如下所示:
[
{
"module_id": 2,
"module_type": "Instructional",
"module_name": "Introduction and Course Overview",
"duration": 30,
"course": {
"course_id": 1,
"course_name": "AWS"
}
},
{
"module_id": 1,
"module_type": "Instructional",
"module_name": "Quiz",
"duration": 20,
"course": {
"course_id": 1,
"course_name": "AWS"
}
}
]
现在,我在 react 中有以下代码,我想在时间轴上渲染它: 时间线代码(材质 - 用户界面)
return(
<Timeline align="alternate">
<TimelineItem>
<TimelineSeparator>
<TimelineDot color="primary">
<LaptopMacIcon />
</TimelineDot>
<TimelineConnector />
</TimelineSeparator>
<TimelineContent>
<Paper elevation={3} className={classes.paper}>
<Typography variant="h6" component="h1">
**Here, I want to display the module_name i.e Introduction and Course Overview and Quiz**
</Typography>
</Paper>
</TimelineContent>
</TimelineItem>
<TimelineItem>
)
请帮忙看看如何做同样的事情,我希望时间轴上有类似这样的笔记本电脑图标
Introduction and Course Overview
|
|
Quiz
提前谢谢你:)
【问题讨论】:
-
您是否尝试过映射您的 json 数据?并且还要先将你的 JSON 数据转换成 js 对象。
标签: json reactjs rest material-ui