我有一些包含数组的 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",}]
现在我的任务是删除subArray
有someString23==red
的部分。 所以当我下次控制台日志时,我必须只得到这个
SomeComponent[
{"someString22":"two","someString23":"red","someString24":"ground",}
{"someString22":"three","someString23":"green","someString24":"air",}]
我该怎么做?
使用如下所示的过滤方法:-
this.subArray = subArray.filter((item) => item["someString23"]!==red);