1.使用@commad,设置事件的名称
<el-dropdown style="padding-left:10px" @command="creatQuest">
<el-button type="primary">创建题目</el-button>
<el-dropdown-menu slot="dropdown" >
<el-dropdown-item command='1'>选择题</el-dropdown-item>
<el-dropdown-item command='2'>多选题</el-dropdown-item>
<el-dropdown-item command='3'>判断题</el-dropdown-item>
<el-dropdown-item command='4'>填空题</el-dropdown-item>
<el-dropdown-item command='5'>解答题</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
2.在下来菜单的每个选项中,绑定command值,相当于赋value
3.在方法中带入参数,当我们对下拉菜单操作时,选中的选项会将command的值,传递给形参questType,然后就可以用条件判断,对选中的不同菜单,进行相应操作
creatQuest(questType){
if(questType==1){
this.showChoice=true;
}else if(questType==2){
this.showLotChoice=true;
}else if(questType==3){
this.showJudge=true;
}else if(questType==4){
this.showFull=true;
}else if(questType==5){
this.showExplain=true;
}
},