Вот пример JSON. Я хочу скрыть показать вопрос на основе видимого свойства if в Json.
Q1 ==> Q2,Q3,Q4,Q5,Q8,Q12
Q5 ==> Q6,Q7
Q6 => Q9,Q10
Q10=>Q11
Json пример:
[{
"id": "1",
"name": "Q1",
"visibleIf": null,
"hasChild": true,
"isparentQuestion": true,
"label": "Question 1"
},
{
"id": "2",
"type": "dropdown",
"name": "Q2",
"visible": false,
"isparentQuestion": false,
"visibleIf": "Q1",
"label": "Question 2"
}, {
"id": "3",
"type": "dropdown",
"name": "Q3",
"visible": false,
"isparentQuestion": false,
"visibleIf": "Q2",
"label": "Question 3"
}, {
"id": "4",
"type": "dropdown",
"name": "Q4",
"visible": false,
"isparentQuestion": false,
"visibleIf": "Q3",
"label": "Question 4"
}
]
recursiveFunc(isChecked, question, item) {
if (isChecked) {
if (item.name == question.visibleIf) {
question.visible = true
}
} else {
if (item.name == question.visibleIf) {
question.visible = false;
//
} else if (question.visibleIf == null) {
question.visible = true;
}
else {
this.temp = question;
if (question.hasChild) {
this.recursiveFunc(false, question, this.temp)
}
}
Вот пример Пример кода