[{"valie1":"日期","valie2":"品种","valie3":"燃料级别","valie4":"结算重量","valie5":"水分","valie6":"灰分","valie7":"低位热值","valie8":"占比"},{"valie1":"2023-07-01","valie2":"树根Z","valie3":"一级","valie4":"8.66","valie5":"29.9","valie6":"5","valie7":"2100","valie8":"0.72%"},{"valie1":"2023-07-01","valie2":"枝丫Z","valie3":"一级","valie4":"6.7","valie5":"41.2","valie6":"10","valie7":"2200","valie8":"0.56%"},{"valie1":"2023-07-01","valie2":"薪材S","valie3":"一级","valie4":"107.48","valie5":"44.24","valie6":"13.11","valie7":"1848.74","valie8":"8.99%"},{"valie1":"2023-07-01","valie2":"板皮S","valie3":"一级","valie4":"619.2","valie5":"32.61","valie6":"13.74","valie7":"2287.92","valie8":"51.76%"},{"valie1":"2023-07-01","valie2":"枝丫S","valie3":"一级","valie4":"414.92","valie5":"40.99","valie6":"28.17","valie7":"1502.87","valie8":"34.69%"},{"valie1":"2023-07-01","valie2":"边角余料S","valie3":"一级","valie4":"39.22","valie5":"54.03","valie6":"14.93","valie7":"1398.96","valie8":"3.28%"},{"valie1":"合计","valie2":"","valie3":"","valie4":"1196.18","valie5":"37.29","valie6":"18.64","valie7":"1945.14","valie8":"100%"},{"valie1":"2023-07-02","valie2":"树皮S","valie3":"一级","valie4":"39.56","valie5":"48.11","valie6":"12.69","valie7":"1561.51","valie8":"4.28%"},{"valie1":"2023-07-02","valie2":"枝丫S","valie3":"一级","valie4":"266.84","valie5":"38.62","valie6":"24.96","valie7":"1716.44","valie8":"28.89%"},{"valie1":"2023-07-02","valie2":"边角余料S","valie3":"一级","valie4":"39","valie5":"56.83","valie6":"5.24","valie7":"1478.41","valie8":"4.22%"},{"valie1":"2023-07-02","valie2":"枝丫Z","valie3":"一级","valie4":"31.14","valie5":"41.2","valie6":"10","valie7":"2200","valie8":"3.37%"},{"valie1":"2023-07-02","valie2":"薪材S","valie3":"一级","valie4":"133.6","valie5":"39.87","valie6":"15.09","valie7":"1912.4","valie8":"14.47%"},{"valie1":"2023-07-02","valie2":"板皮S","valie3":"一级","valie4":"395.54","valie5":"34.01","valie6":"14.45","valie7":"2202.4","valie8":"42.83%"},{"valie1":"2023-07-02","valie2":"边角余料Z","valie3":"二级","valie4":"17.9","valie5":"29.8","valie6":"3.09","valie7":"2866","valie8":"1.94%"},{"valie1":"合计","valie2":"","valie3":"","valie4":"923.58","valie5":"37.92","valie6":"16.74","valie7":"1974.8","valie8":"100%"}]juqery 对valie1统计返回需要跨几行
时间: 2023-07-17 22:10:40 浏览: 217
要统计 `valie1` 值在数组中出现的行数,你可以使用 jQuery 的 `$.grep()` 方法来过滤出与特定值匹配的对象,并统计匹配的对象数量。以下是一个示例代码:
```javascript
var data = [
{"valie1":"日期","valie2":"品种","valie3":"燃料级别","valie4":"结算重量","valie5":"水分","valie6":"灰分","valie7":"低位热值","valie8":"占比"},
{"valie1":"2023-07-01","valie2":"树根Z","valie3":"一级","valie4":"8.66","valie5":"29.9","valie6":"5","valie7":"2100","valie8":"0.72%"},
{"valie1":"2023-07-01","valie2":"枝丫Z","valie3":"一级","valie4":"6.7","valie5":"41.2","valie6":"10","valie7":"2200","valie8":"0.56%"},
// ...
];
var valueToCount = "2023-07-01";
var count = $.grep(data, function(item) {
return item.valie1 === valueToCount;
}).length;
// 打印统计结果
console.log(count);
```
上述代码使用 `$.grep()` 方法过滤出数组中 `valie1` 值等于 "2023-07-01" 的对象,并使用 `.length` 属性获取过滤结果的长度,即匹配的对象数量。
请注意,上述代码中的 `valueToCount` 变量可以用于指定你要统计的 `valie1` 的值。
希望对你有所帮助!如果有任何疑问,请随时追问。
阅读全文