关于element的select多选,数据回显的问题
在工作中遇到这样一个问题,新建表单时用element的select多选以后,在编辑的时候打开表单发现其他数据能正常显示,多选却无法正常回显。在网上找了很多后,终于解决了这个问题,下面把百度的方法总结一下。
首先:表单中
<el-select
v-model="textForm.receDeptIds"
multiple
filterable
allow-create
default-first-option
placeholder="请选择接收部门">
<el-option
v-for="item in deptData"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
其次,methods中这样写:
// 编辑
handleEdit(data){
this.textShow=true;
this.textForm=data;
this.changeSelect(data); //触发此方法
},
changeSelect(data){
let UserIds=data.receUserIds.toString();
let peoData=UserIds.split(',')