VUE element-UI 的 el-select 绑定对象类型,设置初始值,不能正确显示

element-UI 的 el-select 组件里,当 v-model 绑定为对象类型,并对其设定默认值

<el-select v-model="form.InWindowPositionType">
    <el-option v-for="item in positionList" :value="item.value" :key="item.value" :label='item.label'></el-option>
</el-select>

在 data 中设 form.InWindowPositionType 与 列表的 value 相等 ,则认为对 selected 设置了默认值,但是选择器里的显示结果为 value 值,而非 label ,

{ value: 1, label: 'java' },
{ value: 2, label: 'node' },
{ value: 3, label: 'python' },

问题在于数据类型,form.InWindowPositionType 的值为 String ,而 列表的 value 为 Number,并不全等,导致无法找到对应的项 。。。所以需要对数据类型进行转换 

原文地址:https://www.cnblogs.com/_error/p/9776582.html