我正在寻找如何在深度 json 对象结构(例如树)数据树上实现 @observable 的最佳解决方案,这可能会非常深入。每个节点都有很多属性,但我只需要观察树节点中的一个属性。只要我这样做
@observable questionnaire = {}
它有效,但我认为那是腰部。我只需要观察“选定”属性。这是json结构。如果我错了,请纠正我这里是简化的问卷对象。
[
{
"id": "1",
"title": "level 1",
"description": "text",
"type": "Question",
"selected": false,
"childNodes": [
{
"title": "level 2",
"description": "text",
"type": "Question",
"selected": false,
"childNodes": [
{
"title": "level 3",
"description": null,
"type": "Question",
"selected": false,
"childNodes": [
{
"title": "level 4 1",
"childNodes": [],
"description": null,
"type": "Checkbox",
"selected": false
},
{
"title": "level 4 2",
"childNodes": [],
"description": null,
"type": "Checkbox",
"selected": false
},
{
"title": "level 4 3",
"childNodes": [],
"description": null,
"type": "Checkbox",
"selected": false
},
...
]
}, ...