H5 JS 一行代码 对列表数据求和
对数据计算账单服务 数据如下
const data = {
"count": 1600,
"items": [
{
"uuid": "1b9e96cdb6274468b675450f27c20621",
"order_no": "1697858954012799e5c73640ab884",
......
"amount": 99.99,
"staff": 2,
"staff_username": ""
}
]
};
浏览器直接打开 控制他
console.log('总金额:', data.items.reduce((acc, cur) => acc + cur.amount, 0));
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/17792470.html