Comments (12)
你要展示 label
应该用 Select 动态加 option
,AutoComplete 是输入框不是选择器。
from ant-design.
你要展示 label 应该用 Select 动态加 option,AutoComplete 是输入框不是选择器。
+1
from ant-design.
你要展示 `label` 应该用 Select 动态加 `option`,AutoComplete 是输入框不是选择器。
我知道,这是正常Case, 使用没有问题。
但是,我们有一个需求是这样的:一个input同时支持可输/可选。所以我们V3是用AutoComplete做了二次封装。现在发现功能没了。。。
from ant-design.
最好把你的需求详细展开说说。
from ant-design.
最好把你的需求详细展开说说。
主要问题就是Autocomplete,options配置了 { value, label },选择的时候是默认显示value的,无法显示label。刚才本来想通过Children的input value去自定义显示内容,好像没成功。不行只能自己写一个了,先这样吧,周末愉快。
from ant-design.
我是问你的原始需求,具体是什么业务场景的什么输入框需要同时支持可输/可选,又希望展示 label 而不是 value。另外这是单选还是多选?
from ant-design.
如果是多选你可以使用:https://ant.design/components/select-cn#select-demo-tags
from ant-design.
我是问你的原始需求,具体是什么业务场景的什么输入框需要同时支持可输/可选,又希望展示 label 而不是 value。另外这是单选还是多选?
原始需求其实是两个:就是输入时,1. 先调接口查询展示一个列表,供用户选择(这部分Select可满足)2. 如果列表没有匹配项,保留用户输入的结果(相当于新增一条记录,Autocomplete组件功能)
关于展示问题:为什么要展示Label而不是Value,因为value我们是我们和后台交互用的,一般都是id,显示出来没有意义,label才是用户能识别的有意义的名称。
from ant-design.
保留用户输入的结果(相当于新增一条记录,Autocomplete组件功能)
用户输入的内容是 value 还是 label 呢?
from ant-design.
保留用户输入的结果(相当于新增一条记录,Autocomplete组件功能)
用户输入的内容是 value 还是 label 呢?
用户输入的是Label,新增成功后,后台会生成对应ID。
from ant-design.
https://stackblitz.com/edit/react-e2zkty?file=demo.tsx
tags + maxCount 感觉比较适配你的诉求。
<Select
mode="tags"
maxCount={1}
/>
from ant-design.
https://stackblitz.com/edit/react-e2zkty?file=demo.tsx
tags + maxCount 感觉比较适配你的诉求。
<Select mode="tags" maxCount={1} />
我明白你的意思,这是一个解决方案。实际上我已经参照autocomplete的定义,把输入、选择功能封装好了,正在调dropdown的UI。这样改,我只需要替换我们的common-lib中对应组件,不需要改其它使用的地方。
from ant-design.
Related Issues (20)
- Time centering error
- table demo示例中远程加载数据,第一次会出现两次请求的bug HOT 3
- Form中,Checkbox.Group options支持虚拟列表 HOT 5
- Tabs do not work properly if the tab key contains a backslash HOT 1
- Paragraph copyable支持修改tabindex HOT 2
- Tooltip 嵌套 Select使用 严格模式下报错:Warning: findDOMNode is deprecated in StrictMode. HOT 1
- [email protected] is an empty package in npmjs HOT 6
- menu组件主题色的itemActiveBg配置不生效 HOT 1
- ColorPicker被Form.Item包裹,value不生效
- Tooltip not working on mobile devices HOT 1
- Select label render 支持自定义用户自己处理迭代 HOT 9
- The filter in a table does not clear its state when closed when use filterOnClose - false HOT 1
- Datepick.RangePicker picker="month", set disabledDate, can't select first month to last month HOT 1
- want to placeholder to be showed permanent , don't want to show selected items in treeselect bar HOT 2
- Badge 数字没有居中 HOT 1
- DatePicker.RangePicker 的 disabledTime 属性。 结束时间小于等于开始时间的部分都需要禁用(小时 分钟 秒) HOT 2
- Form.Item在Modal中使用,设置help,marginBottom问题 HOT 8
- ant design website mobile view menu overlapping issue HOT 1
- DatePicker在上下空间都不够的情况下无法展现全部 HOT 5
- 每行有200 列,但是没有触发横向虚拟滚动,使用的是官网demo HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ant-design.