VUE 下拉框选择时给其他文本框赋值


    <el-form ref="rowForm" :model="row" :rules="rules" label-width="100px">
      <el-form-item label="参会机构名" prop="institutionName">
        <el-input v-model="row.institutionName" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="机构图标" prop="institutionIcon">
        <ali-upload-image v-model="row.institutionIcon" :limit="1"/>
      </el-form-item>
      <el-form-item label="已注册的机构" prop="courseTags">
        <el-select v-model="row.institutionId" filterable clearable placeholder="请选择已注册的机构" @change="onInstitutionChange">
          <el-option
            v-for="(item,index) in institution"
            :key="item.id"
            :label="item.institutionName"
            :value="index"
          />
        </el-select>
      </el-form-item>
    /**
     * 选择了已注册机构
     */
    onInstitutionChange(obj) {
      this.row.institutionId = this.institution[obj].id
      this.row.institutionIcon = this.institution[obj].institutionIcon
      this.row.institutionName = this.institution[obj].institutionName
    }

change事件的 obj 是el-option中的value属性

Logo

前往低代码交流专区

更多推荐