Both the name and value of the select drop-down box in the Vue element are passed to the background

I recently encountered a small problem that the value and name of the select drop-down box must be passed to the background

The solution is as follows:

  1. First write a chang event
 <el-select v-model="bpmData.typeCode" placeholder="请选择所属分类类型" clearable @change="majorChange($event)">
<el-option v-for="item in typeArray" :key="item.id" :label="item.name"
               :value="item.value"></el-option>
  </el-select>
  1. In the methods method, assign the obtained value to the value you want to pass to the background
majorChange(val){
    
    
   let result = null;
   result = _.find(this.typeArray, function(item) {
    
    
     return item.value == val;
   });
   if(result){
    
    
     this.form.typeText = result.name;
   }
 },

this.typeArray This is your drop-down box array
this.form.typeText This is the name value passed to the background by your form

The above is the solution to the problem, so that the value and name of the drop-down box will be passed to the background.

Guess you like

Origin blog.csdn.net/li22356/article/details/122623363