参考于 carmen_shao的element-ui select下拉框默认值的问题
需要把el-select绑定的sPerforIndicator.id 和 el-option中的 :value="item.id"的id值 设置成一样
注意: 类型也要保持一致
html
<el-select v-model="sPerforIndicator.id" placeholder="请输入关键词"
filterable remote :remote-method="getPerforIndicatorList"
:loading="perforIndicatorListloading">
<el-option-group
v-for="group in perforIndicatorAllList"
:key="group.label"
:label="group.label">
<el-option
v-for="item in group.options"
:key="item.id"
:label="item.title"
:value="item.id">
<span style="float: left">{{item.title}}-{{ item.id }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ typeof item.id }}</span>
</el-option>
</el-option-group>
</el-select>
js
perforId 为 要设置的默认值,this.sPerforIndicator.id为下拉框绑定的值
this.sPerforIndicator.id = Number(perforId);// 将String转为Number
console.log('原指标id类型:', typeof perforId);
console.log('转换后的指标id:', this.sPerforIndicator.id, typeof this.sPerforIndicator.id);
页面效果
版权声明:本文为weixin_41297991原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。