首先要分清楚:el-select中 v-model绑定的是将要在表单中提交的值;
el-select中如果有多个选择,
方案一列举,按照官网案例:
方案二v-for循环遍历:
场景如下:
待提交的表单中存在select选择器,选择的值要作为内容进行提交:
<el-form-item
label-width="110px"> <el-select v-model="ParamsObj.depart" placeholder="归口部门选择"> <el-option v-for="(dict,index) in mgeDepartStatusOptions" :key="index" :label="dict.descValue" :value="dict.code"/> </el-select> </el-form-item>
mgeDepartStatusOptions:[
{
"code": "测试", //选中绑定的
"descValue": "测试" //显示的值
},
{
"code": "报表指标",
"descValue": "报表指标"
},
{
"code": "收入分类",
"descValue": "收入分类"
},
]
ParamObj:{
depart:""
}
<el-form-item label-width="110px">
<el-select v-model="ParamsObj.depart" placeholder="归口部门选择">
<el-option
v-for="(dict,index) in fromData2.mgeDepartStatusOptions"
:key="index"
:label="dict.descValue"
:value="dict.code"/>
</el-select>
</el-form-item>