1.在使用elemnt UI Select 回显数据出现的问题。
- 问题: 项目使用element ui 组件库,使用select多选下拉框时,编辑页面不知道怎么回显数据?
解答:
1.加载的顺序,应该先加载下拉框要选择的数据,然后在通过编辑查询数据后回显。
2.要保证select下拉的ID和v-model里边的id保持一致。(ID要保持一致)
3.elementUI就会自动的将数据回显了。(会自动将数据回显)
2.示例代码
// HTML
<el-select
v-model="recallArrId"
multiple
filterable
allow-create
default-first-option
placeholder="请选择"
>
<el-option
v-for="item in dataArr"
:key="item.value"
:value="item.value"
:label="item.label"
>
</el-option>
//js
// data数据
data() {
return {
recallArrId: [] ,
dataArr:[]
};
},
// 生命周期函数
created() {
// 回显的数据
this.recallArrId=['0','2'];
// 下拉展示的数据
this.dataArr=[{value: '0',label: '不限'},
{value: '1',label: '国有'},
{value: '2',label: '私有'},
{value: '3',label: '合资'}]
},
3.图片展示
图片展示