我如何在我的反应中使用linq?
我用来安装linq并将其命名为import 'linqjs';
并以这种方式称呼它,
var Enumerable = require('linqjs');
Enumerable.From(wzones)
.OrderBy(function (x) {
return [x.Zone];
})
.GroupBy("$.Zone", null,
function (key, g) {
let result = [
'W'+key,
g.Sum("$.totalItemQuantity")
]
return result;
})
.ToArray()
下面是我添加的wzones数据。我似乎只是在我的反应应用程序中导入linq时遇到问题。因为它总是说Enumarable不是一个功能。
{
"Assignment": "36111",
"Picklist": "PL00001361",
"AssignmentStatus": "Passed",
"Operator": null,
"PickType": "1",
"Zone": "1",
"Region": 2.0,
"startTime": "2018-03-12T08:56:35.01",
"endTime": null,
"createdDate": "2018-03-11T02:00:46.84",
"totalItemQuantity": 137
},
{
"Assignment": "37041",
"Picklist": "PL00001370",
"AssignmentStatus": "Processing",
"Operator": "jrpsaladaga",
"PickType": "1",
"Zone": "4",
"Region": 2.0,
"startTime": "2018-03-12T18:51:05.01",
"endTime": null,
"createdDate": "2018-03-12T16:15:46.21",
"totalItemQuantity": 196
},
{
"Assignment": "37042",
"Picklist": "PL00001370",
"AssignmentStatus": "New",
"Operator": null,
"PickType": "2",
"Zone": "4",
"Region": 2.0,
"startTime": null,
"endTime": null,
"createdDate": "2018-03-12T16:15:46.25",
"totalItemQuantity": 1265
},
答案 0 :(得分:1)
1。安装linq
npm install linq
2。导入linq
import linq from "linq";
3。使用linq
const q = linq
.range(1, 10)
.select(function(i) {
return i * 10;
})
.toArray();
console.log(q);