在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue中select的change事件如何傳遞除了value之外的參數(shù)

vue中select的change事件如何傳遞除了value之外的參數(shù)

這是我的select標(biāo)簽

<Select v-model="formValidate.gateway" @on-change="selectGateway()">
   <Option v-for="item in nowGateway" :value="item._id" :key="item._id">{{ item.name }}</Option>
</Select>

這是我的option數(shù)據(jù)

nowGateway: [
          {name: '59f6e896af985117c4418381', _id: '59f6e896af985117c4418381', type: 'plc'},
          {name: '59f6e896af985117c4418382', _id: '59f6e896af985117c4418382', type: 'das'},
          {name: '59f6e896af985117c4418383', _id: '59f6e896af985117c4418383', type: 'plc'},
          {name: '59f6e896af985117c4418384', _id: '59f6e896af985117c4418384', type: 'das'},
          {name: '59f6e896af985117c4418385', _id: '59f6e896af985117c4418385', type: 'plc'}
        ],

現(xiàn)在我想在@on-change ="selectGateway"事件中同時(shí)獲取選中選項(xiàng)的_id和type值,如何實(shí)現(xiàn)

回答
編輯回答
萌吟

獲取到value再用value去查

//value就是select獲取到的value
function machinetypes(mach) {
    return mach._id == value;
}
console.log(this.nowGateway.find(machinetypes))
2017年7月6日 13:20
編輯回答
乖乖瀦

貌似不可以,select的change時(shí)間只有option的value作為參數(shù)進(jìn)行傳遞。

iview可以設(shè)置label-in-value選項(xiàng),可多傳遞一個(gè)option的label

要不然就把選項(xiàng)在數(shù)組中的index作為value,這樣on-change接到一個(gè)index也好去獲取整個(gè)條目

2017年5月22日 08:03