[英]how can i extract arrays from one array & convert them in object and put them in a new array?
[英]how to extract valuefrom object and put it into array
我想提取 filterPillvalue 並將其放入一個數組中,數組的 output 應該是這樣的:
mode = ['anyValue','Repsonding','Unresponsive']
這是我的嘗試
this.items = [
{
filterPillValue: 'anyValue',
id: 'all-systems',
label: 'All systems'
},
{
filterPillValue: 'Responding',
id: 'responding',
label: 'Responding systems'
},
{
filterPillValue: 'Unresponsive',
id: 'unresponsive',
label: 'Unresponsive systems'
}
];
我的嘗試在這種情況下不起作用
mode = this.items.filter(x=>x.filterPillValue);
這會起作用。
mode = this.items.map(({filterPillValue}) => filterPillValue);
要么
mode = this.items.map((item) => item.filterPillValue);
items = [ { filterPillValue: 'anyValue', id: 'all-systems', label: 'All systems' }, { filterPillValue: 'Responding', id: 'responding', label: 'Responding systems' }, { filterPillValue: 'Unresponsive', id: 'unresponsive', label: 'Unresponsive systems' } ]; const node=items.map(item=>item.filterPillValue) console.log(node)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.