【发布时间】:2021-02-26 20:58:24
【问题描述】:
我的 oninit 中有以下数组设置:
this.tests = [{
status: 0,
testresults: [{
name: 'test',
id: 1
}]
}
]
;
this.tests.push([{
status: 1,
testresults: [{
name: 'test2',
id: 2
}]
}
]
}]);
这个数组按预期工作。我的目标是将查询结果推送到测试内部的 testresults 数组中。
this.tests[0].testresults.push(this.qryresults);
this.tests[1].testresults.push(this.qryresults);
索引 0 正常工作,索引 1 返回以下错误:
"ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'push' of undefined
TypeError: Cannot read property 'push' of undefined"
【问题讨论】:
标签: javascript arrays angular typescript