{carrierCarCnt : 7 carrierCompanyCnt : 3 carrierPersonCnt : 8 customerCnt : 6 customerStationCnt : 12 loginCnt : 89 loginPersonCnt : 0 sourceCnt : 7 supplierCnt : 7}把前面这个对象推到数组中不同的value中去0 {: action : "月" color : "green" icon : "visit-count|svg" title : "访问量" total : 89 value : 7 [[Prototype]] : Object 1 : action : "元" color : "blue" icon : "total-sales|svg" title : "成交额" total : 89 value : 7 [[Prototype]] : Object 2 : action : "周" color : "orange" icon : "download-count|svg" title : "下载数" total : 89 value : 7 [[Prototype]] : Object 3 : action : "年" color : "purple" icon : "transaction|svg" title : "成交数" total : 89 value : 7}
时间: 2023-07-21 13:02:54 浏览: 172
你好!根据你提供的对象,你想将这个对象推送到一个数组中的不同值中,是吗?你可以这样做:
```javascript
const obj = {
carrierCarCnt: 7,
carrierCompanyCnt: 3,
carrierPersonCnt: 8,
customerCnt: 6,
customerStationCnt: 12,
loginCnt: 89,
loginPersonCnt: 0,
sourceCnt: 7,
supplierCnt: 7
};
const array = [
{
action: "月",
color: "green",
icon: "visit-count|svg",
title: "访问量",
total: 89,
value: obj.carrierCarCnt
},
{
action: "元",
color: "blue",
icon: "total-sales|svg",
title: "成交额",
total: 89,
value: obj.carrierCompanyCnt
},
{
action: "周",
color: "orange",
icon: "download-count|svg",
title: "下载数",
total: 89,
value: obj.carrierPersonCnt
},
{
action: "年",
color: "purple",
icon: "transaction|svg",
title: "成交数",
total: 89,
value: obj.customerCnt
}
];
```
以上代码将每个属性的值分别赋给数组中不同对象的value属性。希望对你有所帮助!如果还有其他问题,请随时提问。
阅读全文