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

input problem with trim modifier #4951

Closed
1 task done
tracy2zhang opened this issue Nov 29, 2021 · 5 comments
Closed
1 task done

input problem with trim modifier #4951

tracy2zhang opened this issue Nov 29, 2021 · 5 comments
Labels

Comments

@tracy2zhang
Copy link

tracy2zhang commented Nov 29, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.0.0-alpha.13

Environment

vue3.2.16, chrome 95.0.4638.69,macos12.0.1

Reproduction link

Edit on CodeSandbox

Steps to reproduce

1.给input设置trim修饰符(v-model:value.trim="value")
2.输入任意字符(包括空格),比如" aaaa "

What is expected?

可以正常输入" aaaa ",并且绑定的value值也被trim为"aaaa"

What is actually happening?

无法输入空格

@sendya
Copy link
Member

sendya commented Nov 29, 2021

你提供的 Reproduction 中,输入 " aaaa " 已经是被 trim 为 "aaaa",这应该就是预期行为了吧

如果你想输入框中显示的是 " aaaa " 但实际值是 "aaaa" 这个就跟 v-model 提供的作用有偏差了,不知道你的疑问在哪

@tracy2zhang
Copy link
Author

你提供的 Reproduction 中,输入 " aaaa " 已经是被 trim 为 "aaaa",这应该就是预期行为了吧

如果你想输入框中显示的是 " aaaa " 但实际值是 "aaaa" 这个就跟 v-model 提供的作用有偏差了,不知道你的疑问在哪

就是希望能像原生input的v-model.trim一样不是在input事件的时候就触发trim,而是失焦的change事件时进行trim。这样就不会中断用户的输入导致用户很难输入中间带空格比如"a b"这样的字符串
具体可以看一下这个demo:https://codesandbox.io/s/condescending-archimedes-08z18?file=/src/Demo.vue

@tangjinzhou
Copy link
Member

可以用 blur 事件满足该场景

@tangjinzhou
Copy link
Member

下个版本会支持 lazy,然后可以 v-model:value.lazy.trim

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants