#vue2 uses the select drop-down box in element-ui

#vue2 uses the select drop-down box in element-ui

Without further ado, here’s the code:

 <el-select v-model="value" filterable placeholder="请选择">
     <el-option v-for="(item,index) in options" :key="index" :value="item.value" :label="label">   {
   
   {item.value}}</el-option>
  </el-select>

Write in js:

data(){
    return{
        options: [{
          value: '20人',
          label: 'type1'
        }, {
          value: '50人',
          label: 'type2'
        }, {
          value: '100人',
          label: 'type3'
        }, {
          value: '200人',
          label: 'type4'
        }, {
          value: '1000人',
          label: '选项5'
        }],
        value: '100人'
    }
}

Note the value bound to v-model

Consistent with the value bound to v-model above

Note that
the value in data: 100 is the same as the value bound to v-model of el-select. This is to set the default selected value (when traversing, traverse value, do not traverse label) label is the type of value, value is the value

Guess you like

Origin blog.csdn.net/weixin_47600678/article/details/129366552