前提:各种依赖包已 弄好
html代码
<el-select v-model="numtype2.activityNum" placeholder="请选择活动期数" @change="selectModel($event)">
<el-option v-for="(item, index) in numtype" :label="item.activityNum" :value="index" :key="index">
</el-option>
</el-select>
说明:numtype2 需要自定义一下变量
data:里面
numtype2:{
activityNum:'', //活动期数
id:'', // 活动id
activityName:'' //活动名称 ,根据自己需要的数据自定义
},
numtype:{}, // 从后台获取的数据
methods:
getselectNum(){
agentHttp.postJson('接口').then((data)=>{
this.numtype = data // 从后台获取的数据
})
},
//change事件可以打印测试
selectModel(eh){
//eh索引
this.numtype2.id = this.numtype[eh].id // 获取当前点击 的id赋值给numtype2里面
this.numtype2.activityName = this.numtype[eh].activityName // 获取当前点击 的activityName 赋值给numtype2里面
},
菜逼已写完