gpt4 book ai didi

javascript - 具有对象数组的对象

转载 作者:行者123 更新时间:2023-11-28 13:16:27 25 4
gpt4 key购买 nike

我正在尝试创建一个包含 JavaScript 中的对象数组的对象

var alertArray = {
{threshold: 'critical', deviceName: 'Device Agg-02-01', text: 'CPU exceeding policy threshold of 80%', time: '7:00 PM'},
{threshold: 'critical', deviceName: 'Device Leaf-12-22', text: 'Memory utilization exceeding 40%', time: '6:34 PM'},
{threshold: 'warning', deviceName: 'Leaf10-12', text: 'New Software available for upgrade on device', time: '5:10 PM'},
{threshold: 'warning', deviceName: 'Leaf10-11', text: 'New Software available for upgrade on device', time: '4:32 PM'}
};

我不明白我做错了什么,请帮助

最佳答案

你忘记了数组部分:

var alertArray = {
someArray: [{threshold: 'critical', deviceName: 'Device Agg-02-01', text: 'CPU exceeding policy threshold of 80%', time: '7:00 PM'},
{threshold: 'critical', deviceName: 'Device Leaf-12-22', text: 'Memory utilization exceeding 40%', time: '6:34 PM'},
{threshold: 'warning', deviceName: 'Leaf10-12', text: 'New Software available for upgrade on device', time: '5:10 PM'},
{threshold: 'warning', deviceName: 'Leaf10-11', text: 'New Software available for upgrade on device', time: '4:32 PM'}]
};

关于javascript - 具有对象数组的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37565216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com