这是我的档案
const tabledata =
{ 0:
{ Id: 1
, name: 'test1'
, parameters:
[ { name: 'application_instance', value: 'home', type: 'generic' }
, { name: 'application_name', value: 'initial', type: 'generic' }
, { name: 'application_role', value: 'disk_init_role', type: 'generic' }
, { name: 'customer_environment', value: 'development', type: 'generic' }
, { name: 'customer_name', value: 'guest', type: 'generic' }
] }
, 1:
{ Id: 2
, name: 'test2'
, parameters:
[ { name: 'application_instance', value: 'home', type: 'generic' }
, { name: 'application_name', value: 'disk_init', type: 'generic' }
, { name: 'application_role', value: 'initial', type: 'generic' }
, { name: 'customer_environment', value: 'development', type: 'generic' }
, { name: 'customer_name', value: 'guest', type: 'generic' }
] }
, 2:
{ Id: 3
, name: 'test3'
, parameters:
[ { name: 'application_instance', value: 'home', type: 'generic' }
, { name: 'application_name', value: 'initial', type: 'generic' }
, { name: 'application_role', value: 'initial', type: 'generic' }
, { name: 'customer_environment', value: 'development', type: 'generic' }
, { name: 'customer_name', value: 'guest', type: 'generic' }
] }
, 3:
{ Id: 4
, name: 'test4'
, parameters:
[ { name: 'application_instance', value: 'home', type: 'generic' }
, { name: 'application_name', value: 'initial', type: 'generic' }
, { name: 'application_role', value: 'disk_init_role', type: 'generic' }
, { name: 'customer_environment', value: 'development', type: 'generic' }
, { name: 'customer_name', value: 'guest', type: 'generic' }
] }
, 5:
{ Id: 5
, name: 'test5'
, parameters:
[ { name: 'application_instance', value: 'home', type: 'generic' }
, { name: 'application_name', value: 'initial_disk_init', type: 'generic' }
, { name: 'application_role', value: 'disk_initial', type: 'generic' }
, { name: 'customer_environment', value: 'development', type: 'generic' }
, { name: 'customer_name', value: 'guest', type: 'generic' }
] } }
我需要过滤所有已删除的数据 name
属于 'application_role'
和 value
属于 'initial'
我尝试了不同的过滤器,但它们都给出了错误的结果,因为在应用程序的名称中有一个olso值initial,过滤器将此值添加到结果中。
因此,数据需要明确说明:
parameters[x].name === 'application_role' parameters[x].value === 'initial'
1条答案
按热度按时间ewm0tg9j1#
使用
Array.prototype.filter
及Array.prototype.some
为了实现你的目标。试试这个-