【问题标题】:How to get ID from select box in vuejs如何从 vuejs 中的选择框中获取 ID
【发布时间】:2020-11-20 14:33:41
【问题描述】:

我正在尝试从此 JSON 中获取 idTipoExame

{
  "idTipoExame": "11",
  "mnemonico": "AUR",
  "exame": "ACIDO URICO"
},
{
  "idTipoExame": "24",
  "mnemonico": "BTF",
  "exame": "BILIRRUBINA TOTAL E FRACOES"
},

我尝试使用@change,但我从 target.value 获得了“exame”。 这是我的代码 Html 和我的函数:

Javascript:

ExameEvent(event) {
console.log(event.target.value)
}

HTML:

 <select v-model="Exame" @change="ExameEvent($event)>
    <option v-for="item in JSON" :key="item.JSON">{{item.exame}}</option>
  </select>

【问题讨论】:

标签: javascript html json vue.js


【解决方案1】:

您可以将值添加到选项标签,然后从事件中获取值。

<option v-for="item in JSON" :key="item.JSON" :data-id="item.idTipoExame">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-10
    • 2019-03-23
    相关资源
    最近更新 更多