我有一个包含 1000 个元素的对象数组,其中每个对象都有以下属性: 名称、实体、类型、中、低、高。我必须对整个数组 [{},{},..] 执行以下检查:
(注意:类型可以是“静态”或“动态”)
if( type === 'static' ) ---> 然后检查 if( mid || high || low ) 是否为空或负 ----> 然后才执行批量请求。
if( type === 'dynamic' ) ---> 然后通过
示例 - 如果我有 800 个元素,甚至其中 1 个元素的type = 'static' && high、mid 或 low中的任何一个为负数或为空,那么整个 800 个元素根本不应该发送到后端,而是显示向用户发送消息以更正该 1 元素数据。
我尝试了很多逻辑,但没有任何作用,下面是我最新尝试的(使用 array.some()):
import {Component, OnInit} from '@angular/core';
/**
* @title Button varieties
*/
@Component({
selector: 'button-types-example',
templateUrl: 'button-types-example.html',
styleUrls: ['button-types-example.css'],
})
export class ButtonTypesExample implements OnInit {
data = [
{
name: "alpha.keyword#acre-access-reviews-dev|cpu.usage.limit.pct#avg",
entity: "alpha.keyword#acre-access-reviews-dev|cpu.usage.limit.pct#avg",
type: "static",
mid: "-1",
low: "-3",
high: "",
},
{
name: "alpha.keyword#alphasi500-dev|cpu.usage.limit.pct#avg",
entity: "alpha.keyword#alphasi500-dev|cpu.usage.limit.pct#avg",
type: "dynamic",
mid: "",
low: "",
high: ""
},
{
name: "alpha.keyword#ams-dev|cpu.usage.limit.pct#avg",
entity: "alpha.keyword#ams-dev|cpu.usage.limit.pct#avg",
type: "dynamic",
mid: "",
low: "",
high: ""
},
{
name: "alpha.keyword#analytics-services-dev|cpu.usage.limit.pct#avg",
entity: "alpha.keyword#analytics-services-dev|cpu.usage.limit.pct#avg",
type: "dynamic",
mid: "",
low: "",
high: ""
},
{
name: "alpha.keyword#appsec-dev|cpu.usage.limit.pct#avg",
entity: "alpha.keyword#appsec-dev|cpu.usage.limit.pct#avg",
type: "dynamic",
mid: "",
low: "",
high: ""
},
幕布斯6054654
胡子哥哥
智慧大石
相关分类