vue使用el-select选中后获取该对象并且取出该对象的某个属性值
时间: 2024-05-16 12:17:20 浏览: 84
可以使用`v-model`绑定选中的值,然后在其对应的`change`事件中获取该对象并取出所需属性值,例如:
```html
<template>
<div>
<el-select v-model="selectedOption" @change="handleChange">
<el-option
v-for="option in options"
:key="option.value"
:label="option.label"
:value="option">
</el-option>
</el-select>
</div>
</template>
<script>
export default {
data() {
return {
options: [
{ value: 'option1', label: 'Option 1', desc: 'Description 1' },
{ value: 'option2', label: 'Option 2', desc: 'Description 2' },
{ value: 'option3', label: 'Option 3', desc: 'Description 3' }
],
selectedOption: null
};
},
methods: {
handleChange() {
console.log(this.selectedOption.desc); // 输出选中项的描述
}
}
};
</script>
```
在上面的例子中,我们使用了`v-model`将选中的值绑定到`selectedOption`上,并在`change`事件中通过`this.selectedOption.desc`获取选中项的`desc`属性值。
阅读全文
相关推荐


















