zoukankan      html  css  js  c++  java
  • iView之select获取value和label

    使用: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="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"里已能获取,所以可不用再取。
    },

     

  • 相关阅读:
    H5页面富文本展示图片之间存在空隙
    如何关闭eslint语法校验
    K8S service详解
    vim添加或删除多行注释
    K8S 弹性伸缩
    Load高问题排查
    Dockerfile CMD和ENTRYPOINT
    nginx配置
    sed命令
    Pod排错指南
  • 原文地址:https://www.cnblogs.com/phpli/p/10722058.html
Copyright © 2011-2022 走看看