Skip to content
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

[Select] 输入框中回显的数据应该为label #5088

Open
ryanexo opened this issue Feb 25, 2025 · 4 comments
Open

[Select] 输入框中回显的数据应该为label #5088

ryanexo opened this issue Feb 25, 2025 · 4 comments
Labels
need reproduce need to reproduce this issue with sandbox or code

Comments

@ryanexo
Copy link

ryanexo commented Feb 25, 2025

这个功能解决了什么问题

popup的显示逻辑和input的显示逻辑不一致

你建议的方案是什么

我觉得这个组件是否应该设置两个v-model,一个v-model:label一个v-model:value。

即使不这么做,输入框也应该回显label吧。

不然在select popup中,label作为显示的内容,而选中后是value作为显示的内容,用起来会很奇怪。

比如有如下数据:
[{label: 'A', value: 1}, {label: 'B', value: 2}, {label: 'C', value: 3}]

在popup弹出时,用户看到的是A、B、C三项,选中后,输入框的内容变成了1/2/3,他都不知道这三个数字是哪里来的,明明选的是字母,回显的却是数字,而且根本不知道自己是否选对了。

导致我现在只能用computed来手动颠倒两个对应字段。

Copy link
Contributor

👋 @ryanexo,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@uyarn
Copy link
Collaborator

uyarn commented Feb 27, 2025

没看明白这个问题 输入框展示的也是label字段的 能否提供你这个情况的复现代码
https://stackblitz.com/edit/gihikbz8?file=package.json,src%2Fdemo.vue
Image

@uyarn uyarn added the need reproduce need to reproduce this issue with sandbox or code label Feb 27, 2025
Copy link
Contributor

你好 @ryanexo, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。

@ryanexo
Copy link
Author

ryanexo commented Mar 3, 2025

没看明白这个问题 输入框展示的也是label字段的 能否提供你这个情况的复现代码 https://stackblitz.com/edit/gihikbz8?file=package.json,src%2Fdemo.vue Image

codesandbox示例

之前是单纯的以为value-type=object引起的,然后在回复时复现问题发现是在使用了keys的情况下有问题,当时手头忙没顾上详细描述,想到什么就说什么了。

我本地是1.10.7,会出现我问题描述的情况。

在codesandbox是1.11.1,颠倒的问题还存在,只不过输入框正常了,popup又有问题了。popup里使用keys后,展示的是value

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need reproduce need to reproduce this issue with sandbox or code
Projects
None yet
Development

No branches or pull requests

2 participants