el-select中自定义 两组el-option,但是key不一样,并且点击需获取当前整个项的所有属性
当el-select中只有一组el-option , 获取点击的当前项的属性 , el-select 绑定:value-key='id'
但是 当el-select中有两组el-option ,每组option的key不一致,如下代码所示
<el-selectv-model="sth" @change="choosee":value-key="getValueKey(sth)"><template ><el-optionv-for="item in FirstGroup":key="item.id":label="item.name":value="item"/></template><template ><el-optionv-for="item in SecondGroup":key="item.optionId":label="item.optionlabel":value="item"/></template>
</el-select>
对value-key做处理
const getValueKey = (value) =>{if (value?.optionId) return "optionId"; return "id"; // 默认用 id}