我有这样的数据结构
var data = {
'app.state1': {
some: {...},
sequences: [
{...},
{...},
{...}
]
},
'app.state2': {
some: {...},
sequences: [
{...},
{...}
]
}
};
我希望在sequences
0
获取data['app.state1']
我试图像这样实现它
var seq = _.get(data,
'data[' + currentState + '].sequences[' + currentSequence +']');
或者像这样
var seq = _.get(data,
'data[\'' + currentState + '\'].sequences[' + currentSequence +']');
两者都不起作用......我相信currentState
的问题是内部的点(app.state1
或app.state1.substate2
例如)。有什么想法吗?
答案 0 :(得分:2)
你结合得多,检查一下:
var seq = _.get(data, [currentState, 'sequences', currentSequence]);