el-select回显

el-select单选回显

html 复制代码
<el-form-item label="获奖单位" prop="awardeeUnit">
  <el-select v-model="form.awardeeUnit" filterable remote :remote-method="searchDept" placeholder="请输入获奖单位搜索">
    <el-option v-for="item in deptOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
  </el-select>
</el-form-item>


this.deptOptions = [{label: result.awardeeUnitLabel, value: result.awardeeUnit}]

el-select多选回显

html 复制代码
<el-form-item label="获奖人" prop="awardee">
  <el-select v-model="form.awardee" multiple filterable remote :remote-method="searchEmployee" placeholder="请输入获奖人搜索">
    <el-option v-for="item in employeeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
  </el-select>
</el-form-item>

// 多选回显,字符串数组
this.form.awardee = JSON.parse(response.data.awardee).map(String)
this.employeeOptions = result.employeeOptions

完整js代码

javascript 复制代码
/** 修改按钮操作 */
async handleUpdate(row) {
  this.loading = true;
  this.reset();
  const id = row.id || this.ids
  await getTechnologyAwards(id).then(response => {
    const result = Object.assign({},response.data)
    this.loading = false;
    this.form = response.data;
    this.open = true;
    this.title = "修改科技奖项";

    // 多选回显,字符串数组
    this.form.awardee = JSON.parse(response.data.awardee).map(String)
    this.employeeOptions = result.employeeOptions
    // 单选回显
    this.projectOptions = [{label: result.relatedProjectLabel, value: result.relatedProject}]
    this.deptOptions = [{label: result.awardeeUnitLabel, value: result.awardeeUnit}]
  });
},
相关推荐
绝世唐门三哥3 分钟前
使用Intersection Observer js实现超出视口固定底部按钮
开发语言·前端·javascript
南山安7 分钟前
Vue学习:ref响应式数据、v-指令、computed
javascript·vue.js·面试
小胖霞12 分钟前
企业级全栈 RBAC 实战 (11):菜单管理与无限层级树形表格
vue.js·前端框架·前端工程化
鲸落落丶19 分钟前
Vue Router路由
前端·javascript·vue.js
阿呜的边城23 分钟前
终于还是吃上了react-i18next的细糠
前端·前端框架
米方31 分钟前
ElementPlus 穿梭框支持批量穿梭
前端·javascript·vue.js
InkHeart32 分钟前
uni-app开发路上的坑
前端·vue.js
用户40993225021232 分钟前
Vue3中v-bind:class与v-bind:style如何实现条件样式、组件样式合并与深层响应式管理?
前端·ai编程·trae
还算善良_39 分钟前
【Vue】表格实现表头多彩
javascript·vue.js·ecmascript
我是天龙_绍40 分钟前
如何在前端开发中高效运用AI:从提效到避坑
前端