我可以使用temp.get获得Activity(' Activity');
如何按活动ID获取Todos数组?
Activity > id: 1 > Todos [All Objects]
var temp = Immutable.fromJS([
{
id: 1, userName: 'test', isActive: true,
Activity: [
{
id: 1, text: 'This is Activity 1', isCompleted: false, addedOn: '', Todos: [
{ id: 1, text: 'Activity 1 Todo 1', isCompleted: false, progress: [1] },
{ id: 2, text: 'Activity 1 Todo 2', isCompleted: true, progress: [2] },
{ id: 3, text: 'Activity 1 Todo 3', isCompleted: false, progress: [3] }
]
}, {
id: 2, text: 'This is Activity 2', isCompleted: false, addedOn: '', Todos: [
{ id: 1, text: 'Activity 2 Todo 1', isCompleted: true, progress: [4] },
{ id: 2, text: 'Activity 2 Todo 2', isCompleted: false, progress: [5] },
{ id: 3, text: 'Activity 2 Todo 3', isCompleted: false, progress: [6] }
]
}
],
}])
修改
以下是更多信息
const result = temp.find(function(obj){return (obj.get('id') === 1 && obj.get('isActive'));});
console.log(result.getIn(['Activity', '0', 'Todo']));
['Activity', '0', 'Todo']
得到我想要的但问题是活动是通过索引检索的,但我希望它按属性ID 。