从对象中删除数组组件



我有一些包含数组的 compllex 组件

this.SomeComponent.subArray
SomeComponent:model1;

模型 1 定义:

someString1:string;
someString2:string;
someString3:string;
subArray[]

模型 2 定义:

someString22:string;
someString23:string;
someString24:string;

现在如果我控制台.log(JSON.stringify(this.SomeComponent.subArray((; 我得到 :

SomeComponent[{"someString22":"one","someString23":"yellow","someString24":"water",},
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]

现在我的任务是删除subArraysomeString23==red的部分。 所以当我下次控制台日志时,我必须只得到这个

SomeComponent[
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]

我该怎么做?

使用如下所示的过滤方法:-

this.subArray = subArray.filter((item) => item["someString23"]!==red);

相关内容

  • 没有找到相关文章

最新更新