【发布时间】:2020-12-15 06:43:52
【问题描述】:
我有一个类似的数组
let reportData = [
{
ReportID: 1,
ReportHead: 'Revenue',
collection: 75,
subtasks: [
{
ReportID: 2, ReportHead: 'Plan timeline', collection: 100, isDeleted: false,
},
{
ReportID: 3, ReportHead: 'Plan budget', collection: 100, isDeleted: false,
},
{
ReportID: 4, ReportHead: 'Allocate resources', collection: 100, isDeleted: false,
},
{
ReportID: 5, ReportHead: 'Income complete', collection: 0, isDeleted: false,
}
]
},
{
ReportID: 6,
ReportHead: 'Liabilities',
subtasks: [
{
ReportID: 7, ReportHead: 'Software Specification', collection: 60, isDeleted: false,
},
{
ReportID: 8, ReportHead: 'Develop prototype', collection: 100, isDeleted: false,
},
{
ReportID: 9, ReportHead: 'Get approval from customer', collection: 100, isDeleted: false,
},
]
}
]
我需要从这个数组中获取索引和子数组索引。像数据'ReportID:7'这个数组索引是1,子数组索引是0,打字稿
【问题讨论】:
-
问题出在哪里?
-
我需要从这个数组中获取索引和子数组索引
-
这仍然不是问题,而是要求。问题需要实际的代码不起作用 -> How do I ask a good question、minimal reproducible example,可能还有 How do I ask and answer homework questions?
标签: arrays typescript sub-array