亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從對象中提取值并將其放入數組

如何從對象中提取值并將其放入數組

肥皂起泡泡 2023-03-18 17:39:37
我想提取 filterPillvalue 并將其放入一個數組中,數組的輸出應該是這樣的: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);
查看完整描述

2 回答

?
冉冉說

TA貢獻1877條經驗 獲得超1個贊

這會起作用。

mode = this.items.map(({filterPillValue}) => filterPillValue);

或者

mode = this.items.map((item) => item.filterPillValue);


查看完整回答
反對 回復 2023-03-18
?
牧羊人nacy

TA貢獻1862條經驗 獲得超7個贊

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)


查看完整回答
反對 回復 2023-03-18
  • 2 回答
  • 0 關注
  • 126 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號