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}]
  });
},
相关推荐
-凌凌漆-6 分钟前
【npm】npm的-D选项介绍
前端·npm·node.js
鹿心肺语28 分钟前
前端HTML转PDF的两种主流方案深度解析
前端·javascript
海石1 小时前
去到比北方更北的地方—2025年终总结
前端·ai编程·年终总结
一个懒人懒人1 小时前
Promise async/await与fetch的概念
前端·javascript·html
Mintopia1 小时前
Web 安全与反编译源码下的权限设计:构筑前后端一致的防护体系
前端·安全
输出输入1 小时前
前端核心技术
开发语言·前端
Mintopia1 小时前
Web 安全与反编译源码下的权限设计:构建前后端一体的信任防线
前端·安全·编译原理
林深现海1 小时前
Jetson Orin nano/nx刷机后无法打开chrome/firefox浏览器
前端·chrome·firefox
EchoEcho2 小时前
深入理解 Vue.js 渲染机制:从声明式到虚拟 DOM 的完整实现
vue.js
黄诂多2 小时前
APP原生与H5互调Bridge技术原理及基础使用
前端