select回显应该是label而不是value
导致默认回显错误的直接原因是v-show的数据格式和:value的数据格式不匹配
查看接口返回数据类型和字典返回数据类型,果然一个是string,一个是number,如果后端不能给转换,那么就只能在:value内部转换了
不同格式的解决方法
这里使用JSON.parse()将 'false’转换为false(string转Boolean),因为form.applicationState接收到的是false,字典值是‘false’
<el-form-item label="状态">
<el-select v-model="form.applicationState" filterable placeholder="请选择">
<el-option v-for="item in dict.enable_status" :key="item.id" :label="item.label" :value="JSON.parse(item.value)" />
</el-select>
</el-form-item>
如果是string转换成number类型,加*1就能转换
<el-form-item label="类型">
<el-select v-model="form.applicationType" filterable placeholder="请选择">
<el-option v-for="item in dict.application_type" :key="item.id" :label="item.label" :value="item.value*1" />
</el-select>
</el-form-item>
如果是number转换string,+''即可
<el-form-item label="类型">
<el-select v-model="form.applicationType" filterable placeholder="请选择">
<el-option v-for="item in dict.application_type" :key="item.id" :label="item.label" :value="item.value + ''" />
</el-select>
</el-form-item>