commad使用

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;
      }

    },

 

 

 

 

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值