Element UI 中下拉框获取name 和label
Element UI 中下拉框获取name 和label
<template> <div> <el-select v-model="value" placeholder="请选择" @change="handleCardType"> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> </el-select> </div> </template> <script> /* 这是ElementUI */ import Vue from 'vue' import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; Vue.use(ElementUI); /* 这是ElementUI */ export default { data() { return { options: [{ value: '选项1', label: '黄金糕' }, { value: '选项5', label: '北京烤鸭' }], value: '' } }, methods: { handleCardType(vId){ let obj = {}; obj = this.options.find((item)=>{//数据源 return item.value === vId; }); console.log(vId,obj.label); } }, }; </script> <style scoped></style>