el-select遍历方法,在el-select中有个@change,如@change=“pickRoleName”
<el-select
@change="pickRoleName"
v-model="ToviewForm.deptId"
placeholder="请选择"
class="optionsone"
clearable
>
<el-option
v-for="item in optionsone" // optionsone数组
:key="item.id"
:label="item.deptName"
:value="item.id" //拿到optionsone中的id
></el-option>
</el-select>
js中调用@change="pickRoleName"方法
pickRoleName(e) {
this.optionsone.map((item, i) => {
if (item.id == e) {
this.ToviewForm.deptName = item.deptName; //传值
this.ToviewForm.deptId = item.id;//传值
}
});
},