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}]
  });
},
相关推荐
无心水几秒前
【时间利器】4、JavaScript时间处理全解:Date/moment/dayjs/Temporal
开发语言·前端·javascript·状态模式·openclaw·date/moment·dayjs/temporal
踩着两条虫6 分钟前
AI 驱动的 Vue3 应用开发平台 深入探究(二十五):API与参考之Renderer API 参考
前端·vue.js·人工智能
踩着两条虫6 分钟前
AI 驱动的 Vue3 应用开发平台 深入探究(二十四):API与参考之Provider API 参考
前端·vue.js·ai编程
恋猫de小郭12 分钟前
Android Studio Panda 2 ,支持 AI 用 Vibe Coding 创建项目
android·前端·flutter
爱学习的程序媛14 分钟前
【Web前端】WebSocket 详解
前端·websocket·网络协议·web
BJ-Giser14 分钟前
Cesium夜晚月亮银河夜空效果
前端·可视化·cesium
happymaker062615 分钟前
web前端学习日记——DAY06(js基础语法与数据类型)
前端·javascript·学习
FlyWIHTSKY16 分钟前
父子组件参数传递
前端·javascript·vue.js
紫_龙24 分钟前
最新版vue3+TypeScript开发入门到实战教程之生命周期函数
前端·javascript·typescript
小江的记录本32 分钟前
【反射】Java反射 全方位知识体系(附 应用场景 + 《八股文常考面试题》)
java·开发语言·前端·后端·python·spring·面试