vue 获取下拉框选中的值
<template><div class=""><select @change="getEventType($event)"><optionv-for="option in list":key="option.value":id="option.value":name="option.name"></option>
·
<template>
<div class="">
<select @change="getEventType($event)">
<option
v-for="option in list"
:key="option.value"
:id="option.value"
:name="option.name"
>
</option>
</select>
</div>
</template>
<script>
export default {
name: "",
data() {
return {
list: [{ value: 1, name: "test" }],
index: "",
};
},
components: {},
methods: {
getEventType(id) {
let obj = {};
obj = this.list.find((item) => {
return item.value === id;
});
if (obj !== undefined) {
this.index = JSON.parse(JSON.stringify(obj)).value;
} else {
this.index = "";
}
},
},
};
</script>
<style lang=''>
</style>
更多推荐
已为社区贡献2条内容
所有评论(0)