antd 设计选择占位符问题 [英] antd design select placeholder issues

查看:32
本文介绍了antd 设计选择占位符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 React 应用程序中使用了 antd 设计.

I am using antd design in my React app.

这是我遇到问题的代码片段:

Here's a code snippet where I am facing the issues :

<Select
     showSearch
     optionFilterProp = "children"
     placeholder = "Select Company"
     value = "{this.state.company}"
     name = "company"
     onSelect = "{this.handleCompanyChange}"
    >

如果this.state.company 不是null,它现在显示选择的正确值.但是如果 this.state.companyemptynull,占位符不会出现.

Now it shows the correct value selected if this.state.company is not null. But if this.state.company is empty or null, placeholder doesn't shows up.

如果value 为空,我该如何解决这个问题,以便出现占位符?

How can I solve this issue so that the placeholder appears if value is null?

推荐答案

将 this.state.company 设置为 undefined 而不是 null.

set this.state.company to be undefined instead of null.

这篇关于antd 设计选择占位符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆