Redux中具有动态密钥的Object内的数组

时间:2016-09-29 11:46:17

标签: javascript reactjs redux flux reactjs-flux

鉴于我有一个数组。

var myKey = "myObjectKey";
var anArray = ["apple", "balloon", "dog", "cat"];

anArray.map(function(thing) {
  store.dispatch(Object.assign({type: 'ADD_ITEM', payload: thing, key: myKey}));
});

如何获得以下输出?

store.getState();
# Object: {myObjectKey: ["apple", "balloon", "dog", "cat"]}

1 个答案:

答案 0 :(得分:3)

这应该有效。只需将DataTable.DefaultView.Sort = "ColumnName ASC" DataTable = DataTable.DefaultView.ToTable 传递给调度即可。它将在减速器中进行处理

object