JavaScript 数组对象不可迭代

问题描述 投票:0回答:1

我遇到了一个奇怪的问题,不确定是什么问题。我正在为 API 获取对象,对象在浏览器的控制台中看起来像这样

const obj: any;
this.obj = {"pots":[{"id":"23293839","name":"Label · L5","active":true,"parentid":"23293827","level":4}]}

for (const temp of this.obj['pots']) {}

现在当我试图遍历

pots
数组时,它给我错误提示

this.obj.pots is not iterable

我尝试了各种方法,但找不到解决方案。

Screenshot from browser's console

javascript arrays angular angularjs typescript
1个回答
-2
投票

请分享错误的屏幕截图,我尝试了上面的方法,它工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.