Element-ui的select下拉框传递多个参数方法

本文介绍了如何在Element-ui的select组件中传递多个参数,包括使用`value-key`属性绑定对象以及通过`@change`事件传递额外参数。示例代码展示了如何在选项改变时获取并设置选中项的code和name属性,适用于需要在表单编辑时更新多个字段的情况。
摘要由CSDN通过智能技术生成

Element-ui的select下拉框传递多个参数方法

<el-select v-model="value8" filterable placeholder="请选择" value-key="id" @change="currentSel">
   <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item"></el-option>
</el-select>
options: [
       {
         value: "选项1",
         id: 1,
         code: "xuanxiang1",
         label: "黄金糕"
       },
]
 currentSel(selVal) {
       this.code = selVal.code;
       this.name = selVal.label;
       console.log("选择的name为:" + this.name, "选择的code为:" + this.code);
       console.log(selVal);
   },

或者 (给change函数添加实参形参)

<el-select v-model="value8" filterable placeholder="请选择" value-key="id" @change="value=>{currentSel(value,1)}">
   <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item"></el-option>
</el-select>
options: [
       {
         value: "选项1",
         id: 1,
         code: "xuanxiang1",
         label: "黄金糕"
       },
]
 currentSel(e,num) {
       this.code = selVal.code;
       this.name = selVal.label;
       console.log("选择的name为:" + this.name, "选择的code为:" + this.code);
       console.log(selVal);
   },

修改时需要需要接收一个对象

this.editFormField.sale_name = {
  id_number: info.sale_id_card,
  supplier_name: info.sale_name,
  contacts_phone: info.sale_phone,
};
this.editFormField.purchase_name = {
  merchant_id_number: info.purchase_id_card,
  merchant_mobile_phone: info.purchase_phone,
  merchant_name: info.purchase_name,
};
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cheng Lucky

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值