【发布时间】:2017-01-04 19:36:17
【问题描述】:
我想知道是否有人可以告诉我我在这里做错了什么,我正在尝试使用 _.reduce 来获取对象中的字段,但似乎每次都缺少“第一个”字段。
这里的第一行是plain old js,接下来是lodash。
$scope.actualKeys = Object.keys($scope.item);
_.reduce($scope.item, function(result, value, key) {
$scope.keys.push(key);
});
$scope.item 在哪里
$scope.item = {
field1: 'test',
field2: 'test',
field3: 'test',
field4: 'test',
field5: 'test',
field6: 'test'
};
【问题讨论】: