var Main = { methods:{ change(){ console.log(this.options[this.value]) } }, data() { return { options: [{ value: '选项1', label: '黄金糕' }, { value: '选项2', label: '双皮奶' }, { value: '选项3', label: '蚵仔煎' }, { value: '选项4', label: '龙须面' }, { value: '选项5', label: '北京烤鸭' }], value: '' } }, created(){ setTimeout(()=>{ this.options.forEach((item,index)=>{ if(item.value==='选项5'){ this.value=index } }) },1000) } } var Ctor = Vue.extend(Main) new Ctor().$mount('#app')
@import url("//unpkg.com/[email protected]/lib/theme-chalk/index.css");
<script src="//unpkg.com/vue/dist/vue.js"></script> <script src="//unpkg.com/[email protected]/lib/index.js"></script> <div id="app"> <template> <el-select v-model="value" placeholder="请选择" @change="change"> <el-option v-for="(item,index) in options" :key="item.value" :label="item.label" :value="index"> </el-option> </el-select> </template> </div>