element
select组件显示了value(id)出来,而没有按照预料的显示key(中文)值
<el-select style="display: inline-block; width: 400px; margin-bottom: 15px;" v-model="product.value" filterable remote :disabled="!data.formData.channel_id" reserve-keyword placeholder="请输入关键词" :remote-method="remoteMethod" :clearable="true" @clear="clearText" :loading="product.isLoading"> <el-option v-for="(item,index) in product.options" :key="index" =》 错误❌, :key="item.value" :label="item.key" :value="item.value"> </el-option></el-select>
- 第一步排查数据是否覆盖,发现后面有调用函数把options给覆盖了,修正之后,还是不能显示
- 第二步排查父子组件加载传参是否有问题,没有问题
- 第三步找出官方文档代码,和自己写得一行一行代码进行对比,发现了 el-option得key值,我用了index作为key得变量,然后修改回来唯一值就正常了