【Vue】2.ElementUI中el-select多选情况下获取label和value

el-select选中只能获取到value的值,获取不到label的值,所以要循环匹配筛选获取label的值。

html部分:


js部分:

export default {
    data(){
        return {
            formLabelWidth:"160px",
            labelPosition: "left",
            valueList:[],
            valueListSelected:[],
            options:[
                {
                    value:"1",
                    label:"家安芯A款"
                },
                {
                    value:"2",
                    label:"家安芯B款"
                },
                {
                    value:"3",
                    label:"家安芯C款"
                },{
                    value:"4",
                    label:"家安芯D款"
                },
                {
                    value:"5",
                    label:"家安芯E款"
                },
                {
                    value:"6",
                    label:"家安芯F款"
                },{
                    value:"7",
                    label:"家安芯D款"
                },
                {
                    value:"8",
                    label:"家安芯E款"
                },
                {
                    value:"9",
                    label:"家安芯F款"
                },{
                    value:"10",
                    label:"家安芯D款"
                },
                {
                    value:"11",
                    label:"家安芯E款"
                },
                {
                    value:"12",
                    label:"家安芯F款"
                }],
        }
    },
    methods:{
        insuranceNameSelect(val){
            console.log(val, '==========险种选中==========');
            this.valueListSelected = [];
            for(let i =0; i { //这里的options就是数据源
                    if(item.value == val[i]){
                        this.valueListSelected.push({value:item.value, label:item.label})
                    }
                })
            }
            console.log(this.valueListSelected, '==========valueListSelected===========');
        },
        removeTagSelect(tag){
            console.log(tag, "=========tag=========");
        },
    
    }
}

你可能感兴趣的:(【Vue】,vue.js,elementui,javascript,el-select)