0

我有一个 JSON 数据,我想迭代runStatus,但不是所有节点都有runStatus,我收到错误run.runStatus is Undefined

如何修复 HTML 中的错误?

[
    {
        "Code": "AB",
        "Run": {
            "Range": {
                "maxValue": "75",
                "minValue": "54"
            },
            "remarks": [],
            "runStatus": "RESULTED"
        }
    },
    {
        "Code": "CD",
        "Run": {
            "remarks": []
        }
    }
]
4

1 回答 1

0

先检查一下

if(YOUR_OBJ.Run.runStatus !== undefined)
{
  console.log(YOUR_OBJ.Run.runStatus);
  // ...
}
于 2020-07-09T16:42:54.737 回答