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}]
  });
},
相关推荐
橙序员小站2 小时前
Agent Skill 是什么?一文讲透 Agent Skill 的设计与实现
前端·后端
炫饭第一名4 小时前
速通Canvas指北🦮——基础入门篇
前端·javascript·程序员
王晓枫4 小时前
flutter接入三方库运行报错:Error running pod install
前端·flutter
符方昊4 小时前
React 19 对比 React 16 新特性解析
前端·react.js
ssshooter4 小时前
又被 Safari 差异坑了:textContent 拿到的值居然没换行?
前端
曲折5 小时前
Cesium-气象要素PNG色斑图叠加
前端·cesium
Forever7_5 小时前
Electron 淘汰!新的桌面端框架 更强大、更轻量化
前端·vue.js
不会敲代码15 小时前
前端组件化样式隔离实战:React CSS Modules、styled-components 与 Vue scoped 对比
css·vue.js·react.js
Angelial5 小时前
Vue3 嵌套路由 KeepAlive:动态缓存与反向配置方案
前端·vue.js
jiayu5 小时前
Angular学习笔记24:Angular 响应式表单 FormArray 与 FormGroup 相互嵌套
前端