我有像下面这样的数据,有随机的行数(三级),我想循环这个数据来显示它像下面的表格
const myData = [
{
subject: "Math",
class: [
{
name: "Math-01",
results: [
{student: "jame",score: "10"},
{student: "kelvin",score: "4"},
{ student: "smith",score: "8"}
]
},
{
name: "Math-02",
results: [
{ student: "joe",score: "8"},
{student: "yassou",score: "8"}
]
}
]
},
{
subject: "History",
class: [
{
name: "History-01",
results: [
{student: "zoe", score: "6"},
{student: "jame", score: "8"},
{student: "bean", score: "9"}
]
},
{
name: "History-02",
results: [
{student: "luffy", score: "10"},
]
}
]
},
{
subject: "literature",
class: [
{
name: "literature-01",
results: [
{student: "nami", score: 5}
]
},
{
name: "literature-02",
results: [
{student: "zoro", score: 3}
]
},
{
name: "literature-03",
results: [
{student: "shank", score: 5}
]
}
]
}
]
我试着用这种方法 https://codesandbox.io/s/material-ui-table-demo-with-row-span-dq1w6个 但它只适用于第二级
here is my code at level 2 and it work
and I continue apply this logic for level 3 and it's not working properly
有没有人能帮我换一种方法,我希望表格看起来像我的数据中的第一张图片.
(*)注意:mydata可以有更多不同行数的数据,所以我希望能够动态地构建合并单元格表(但它仍然是相同的格式)
非常感谢.