美文网首页
vue element 怎么获取select选中的对象

vue element 怎么获取select选中的对象

作者: Mr菜头 | 来源:发表于2019-12-10 13:15 被阅读0次

问题:当option 的 value 为对象时,出现无论选中任何选项,都会选中最后的选项
解决方法:在 select 中 加入 value-key
注意:value-key 不是绑定属性
实例:
https://jsfiddle.net/1erjhcL3/1/

<el-select v-model="stationId" value-key='stationID' >
      <el-option v-for="(stn,index) in stationList" :key="index" :value="stn" :label="stn.stationID"></el-option>
</el-select>

相关文章

网友评论

      本文标题:vue element 怎么获取select选中的对象

      本文链接:https://www.haomeiwen.com/subject/lbmwgctx.html