初始化参数
return {
fields: [
{"title":"景区","id":0},
{"title":"酒店","id":1}
],
evaluates: [
{"title":"好评","id":0},
{"title":"中评","id":1},
{"title":"差评","id":2}
],
}
<el-form-item label="评价" prop="appraise">
<el-select v-model="form.appraise" placeholder="请选择">
<el-option
v-for="evaluate in evaluates"
:key="evaluate.id"
:label="evaluate.title"
:value="evaluate.id"
clearable
>
{{ evaluate.title }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="分类" prop="classification">
<el-select v-model="form.classification" placeholder="请选择">
<el-option
v-for="item in fields"
:key="item.id"
:label="item.title"
:value="item.id"
clearable
>
{{ item.title }}
</el-option>
</el-select>
</el-form-item>
文章来源地址https://www.toymoban.com/news/detail-577833.html
后端传送数据给前端后,下拉框回显结果为数字!
最近遇到个问题后端返回结果后.前端双向绑定回显结果为数字.分析原因后发现是数据类型不一致导致回显异常
解决方案
把option的value转为字符类型即可
1 |
:value="evaluate.id+''" |
<el-form-item label="评价" prop="appraise">
<el-select v-model="form.appraise" placeholder="请选择">
<el-option
v-for="evaluate in evaluates"
:key="evaluate.id"
:label="evaluate.title"
:value="evaluate.id+''"
clearable
>
{{ evaluate.title }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="分类" prop="classification">
<el-select v-model="form.classification" placeholder="请选择">
<el-option
v-for="item in fields"
:key="item.id"
:label="item.title"
:value="item.id+''"
clearable
>
{{ item.title }}
</el-option>
</el-select>
</el-form-item>
文章来源:https://www.toymoban.com/news/detail-577833.html
到了这里,关于element-ui select数据回显显示数字的问题 el-select校验失效出现阿拉伯数字问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!