gpt4 book ai didi

reactjs - 如何在 React Js 中使用 Linq

转载 作者:行者123 更新时间:2023-12-02 20:29:07 27 4
gpt4 key购买 nike

如何在 React js 中使用 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 数据。看来我在我的 React 应用程序中导入 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
},

最佳答案

<强>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);

关于reactjs - 如何在 React Js 中使用 Linq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49270237/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com