Ant Design Vue Select 报错 TypeError: Cannot read properties of null (reading ‘key‘)“

Ant Design Vue Select 报错

vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in data(): "TypeError: Cannot read properties of null (reading 'key')"
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of null (reading 'key')
[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'length')"

代码如下

<a-col :span="4">
                      <a-form-model-item label="证件类型">
                        <a-select v-model="registerParam.idCardType" label-in-value placeholder="请选择证件类型" option-filter-prop="children" @change="idCardTypeChange">
                          <a-select-option value="0"> 居民身份证 </a-select-option>
                          <a-select-option value="1"> 居民户口本 </a-select-option>
                          <a-select-option value="2"> 护照 </a-select-option>
                          <a-select-option value="3"> 军官证 </a-select-option>
                        </a-select>
                      </a-form-model-item>
                    </a-col>
                    
                    
const  idCardType=null;

原因分析:

如果你用了 label-in-value ,idCardType就一定要设置 key value, 例如{ key: ‘0’, label: ‘居民身份证’ },如果你没有使用 label-in-value,反而设置了也会报错 Avoid using non-primitive value as key, use string/number value instead.


解决方案:

提示:使用了 label-in-value,一定要对应{ key: ‘0’, label: ‘’ },这种格式!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值