Vue 中 Element UI 单页面使用
<template>
<div>
test
<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 {
components:{},
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);
}
},
watch: {},
};
</script>
<style scoped></style>