New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoComplete选中回显了value #32575
Comments
Hello @theDoinb. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by 你好 @theDoinb, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。 |
设计如此,AutoComplete 是带提示的输入框,所以你 value 是什么它的值就是什么。如果需要展示 label 应该用 Select。 ref: https://ant.design/components/auto-complete-cn/#%E4%BD%95%E6%97%B6%E4%BD%BF%E7%94%A8 |
Try this one. const CustomAutoComplete = (props) => {
const { value, options, onChange, ...restProps } = props;
const handleSelect = (_value, _option) => {
onChange(_option.key);
};
const realOptions = options?.map(v => ({ ...v, key: v.value }));
return (
<AutoComplete
options={realOptions}
onSelect={handleSelect}
{...restProps}
/>
)
} |
value 是什么 它就是什么没错,那我如果只想回填一部分呢,另一部分是去跟其他表单里的值做交互;在这种情况下是不是现在的设计方案就不灵活,现在的方案是只能满足填充自己的值,做联动的话就不太行了 |
Reproduction link
Steps to reproduce
如上链接
What is expected?
选中某个客户时,回显 label 值
What is actually happening?
选中某个客户时,回显 value 值
这个是设计就是这样吗?
像现在好几个需求,要先库里搜索某个客户之类,然后将ID代入参数中。
这种回显让我比较头痛,像客户或者某些数据确实有重复的,用名称没法识别是哪个
如果设计是这样,能否加入类似 showLabelProps 去指定要显示的内容呢
The text was updated successfully, but these errors were encountered: