首先,在data中声明一个值
data() {
return {
dishesInfoList: [],
}
}
其次,在查询遍历列表信息的接口中获取数据
listDishesInfo(this.queryParams).then(response => {
this.dishesInfoList = response.data;
});
之后,在el-form中写上 : data;在el-select中写上v-model(写不写都行);
在el-option里面写上
v-for="item in dishesInfoList"
:key="item.id"
:value="item.shopId"
:label="item.shopId"
具体代码如下:
<el-form ref="form" :data="dishesInfoList">
<el-select
v-model="dishesInfoList.shopId"//在这里写上
placeholder="选择店铺"
clearable
@keyup.enter.native="handleQuery"
>
<el-option v-for="item in dishesInfoList"
:key="item.id"
:value="item.shopId"
:label="item.shopId"
>
</el-option>
</el-select>