element

select组件显示了value(id)出来,而没有按照预料的显示key(中文)值

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