question
I have defined a custom question type, which name is cascadedropdown,the code is as follows:
ComponentCollection.Instance.add({
// A unique name; must use lowercase
name: 'cascadedropdown', // A display name used in the Toolbox
title: 'cascade dropdown', // A default title for questions created with this question type
defaultQuestionTitle: 'choose the options',
elementsJSON: [
{
type: 'dropdown',
name: 'dropdown1',
title: 'question1',
choices: [
{
text:"apple",
value:1,
},
{
text:"orange",
value:2,
}
],
},
{
type: 'dropdown',
name: 'dropdown2',
title: 'question2',
startWithNewLine: false,
choices:getSecondLevelChoices(1)
},
{
type: 'dropdown',
name: 'dropdown3',
title: 'question3',
startWithNewLine: false,
choices:[],
visible: casecadeQuestionList.length > 2
},
{
type: 'dropdown',
name: 'dropdown4',
title: '问题4',
startWithNewLine: false,
choices:[],
visible: casecadeQuestionList.length > 3
},
],
inheritBaseProps: true
})
on the code above, there are at least two dropdowns in the casecadedropdown question, the second dropdown question’s choices depend on the first dropdown answer. the method getSecondLevelChoices(1)
, the parameter 1 is the first dropdown answer’s value.
The question is how to get the first dropdown answer’s value dynamically.
the template is
<SurveyCreatorComponent :model="creator" />