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 分钟前
VTJ.PRO AI Agent 技术白皮书
前端·vue.js·低代码
子兮曰3 分钟前
解剖 Claude Code:从入口架构逆向工程看 AI 编程工具的信任边界设计
前端·后端·claude
先吃饱再说15 分钟前
层层传递太“痛”了:useContext 给 React 组件装了个“无线遥控器”
前端·react.js·前端框架
颜进强18 分钟前
前端看后端 15:什么是 DNS?
前端·后端·ai编程
文艺理科生22 分钟前
LangChain.js-v1-记忆管理最佳实践
前端·javascript·后端
子兮曰30 分钟前
Elysia vs Hono 完整性能对比:Bun 专属优化还是跨平台通用,2026 实测数据给出的答案
前端·后端·typescript
To_OC1 小时前
从一个颜色选择器说起:我终于整明白了 React+TS 里的 model 与 api 分层
前端·react.js·typescript
赵大仁1 小时前
浏览器端 RAG:Transformers.js + WebGPU 本地检索入门
前端·ai·react·webgpu·rag
木叶丸1 小时前
从 Loop 到 Graph:AI 智能体协作系统工程指南
前端·后端·架构
java1234_小锋2 小时前
Vue3专题 - 列表渲染
vue.js