<el-select>标签中当服务器传过来字符串形式的多个下拉keyName时,如果根据返回值动态出下拉框选项

在这里插入图片描述

//this.deductTypeList 为Vm实例中 data()中属性:deductTypeList :[]
let deductType=“1|3”;
let deductTypesArray=deductType.split("|");
  //初始化数组,哈 百度了下 发现这是最直接的:删除所有数组索引的方式
         let deductTypeList2=[];
         this.deductTypeList=deductTypeList2;
         for(let i in deductTypesArray){
           if(deductTypesArray[i]=="1"){
            let deductTypeArray={ 
                  value:"1",
                  label:"天数减免"};
             this.deductTypeList.push(deductTypeArray);
           }else if(deductTypesArray[i]=="2"){
              let deductTypeArray={ 
                  value:"2",
                  label:"金额减免"};
             this.deductTypeList.push(deductTypeArray);
           }else if(deductTypesArray[i]=="3"){
             let deductTypeArray={ 
                  value:"3",
                  label:"期次减免"};
                this.deductTypeList.push(deductTypeArray);
           }
          //整个循环下来后, this.deductTypeList数组就是根据后台返回值,动态出的下拉属性了。用于<el-select>标签中
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值