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

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

问题描述

我在我的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.company empty null ,占位符不显示。

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 design选择占位符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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