template模板:

<el-select v-model="valueClass" placeholder="请选择学生" class="studentSelect">

<el-option

v-for="item in classList"

:key="item.id"

:label="item.className"

:value="item.teacherId">

</el-option>

</el-select>

script :

data:{   

       valueClass:'  '  

}

watch:{

         valueClass   (val, oldval) {

                   // console.log(this.classList[val]);

                      this.afterSwitchClassId = this.classList[val].classId;

                      this.afterSwitchTeacherId = this.classList[val].teacherId;

                     // console.log(this.afterSwitchClassId);

                      //console.log(this.afterSwitchTeacherId)

         }

}

首先要在selecte选择框绑定初始值,然后监听绑定的数据

Logo

前往低代码交流专区

更多推荐