使用:label-in-value="true" @on-change="obtainValue"

详见官方文档:https://www.iviewui.com/components/select

 1 <Select :label-in-value="true" @on-change="obtainValue" v-model="model1" style="width:200px;">
 2                   <OptionGroup v-for="(item,key) in selectList" :label="item.groupName" :key="key">
 3                     <Option
 4                       v-for="(item2,key) in item.data"
 5                       :value="item2.terminalId"
 6                       :key="key"
 7                     >{{ item2.terminalName }}
 8                     </Option>
 9                   </OptionGroup>
10 </Select>

js:

model1: "",

obtainValue(e) {
this.stationLabel = e.label.replace(/(\s*$)/g, ""); // 获取显示在页面的label值,即{{ item2.terminalName }},并且去掉右空格。
     this.model1 = e.value; //获取绑定的:value="item2.terminalId"值,可当做另一接口的入参,这个值,在v-model="model1"里已能获取,所以可不用再取。
},

 iView之select获取value和label

 

相关文章:

  • 2023-02-23
  • 2021-10-16
  • 1970-01-01
  • 2022-12-23
  • 2021-10-24
  • 2021-08-04
  • 2021-12-03
  • 2021-07-24
猜你喜欢
  • 2021-12-21
  • 2021-09-04
  • 2021-04-02
  • 2020-02-18
  • 2021-12-29
  • 2022-12-23
相关资源
相似解决方案