假如dataList为后台假数据,我想分别得到number和chargeTime、number和freeTime,来分别画图,就可以这么写,当然直接for循环更可以。
1 const dataList = { 2 list:[ 3 { 4 number: "0", 5 chargeTime: 2, 6 freeTime: 5 7 },{ 8 Number: "1", 9 chargeTime: 8, 10 freeTime: 9 11 }, 12 ...... 13 ]}; 14 15 const chargeTimeAndNumber = dataList.list.map(item => ({ 16 number:item.number, 17 chargeTime:item.chargeTime 18 })); 19 const freeTimeAndNumber = dataList.list.map(item => ({ 20 number:item.number, 21 freeTime:item.freeTime 22 }));
标签:map,遍历,dataList,number,item,chargeTime,freeTime,需字 From: https://www.cnblogs.com/hyxxl/p/17778425.html