码迷,mamicode.com
首页 > 其他好文 > 详细

iView之select获取value和label

时间:2019-04-17 11:03:42      阅读:2431      评论:0      收藏:0      [点我收藏+]

标签:image   获取   mod   bsp   img   val   http   span   inf   

使用: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: "",
stationLabel: "",

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

标签:image   获取   mod   bsp   img   val   http   span   inf   

原文地址:https://www.cnblogs.com/phpli/p/10722058.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!