We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://stackblitz.com/edit/angular-ftdg2p?file=src%2Fdemo.vue
再组件的v-model上使用trim 将会造成input 内容被清空
v-model.trim在使用频率上还是比较常用的,例如在用户登录 ,表单提交,搜索等地方都是需要将用户输入的内容去掉首尾空 防止后台验证不了数据
已在vue3中使用原生input 测试,该bug 为组件bug
The text was updated successfully, but these errors were encountered:
👋 @zhairy,感谢给 TDesign 提出了 issue。 请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。
Sorry, something went wrong.
任何人都可以处理此问题。 请务必在您的 pull request 中引用此问题。 ✨ 感谢你的贡献! ✨
pull request
分析一下这个问题
下图为 vue 处理 trim 修饰符的过程,即在 emit 时直接对所传参数 rawArgs 依次调用 trim() 函数来实现功能
vue
trim
emit
rawArgs
trim()
在我们的 useVmodel 中,当改变受控数据时,会直接调用 emit 函数并且接收参数,如下:
useVmodel
因此,当用户使用 v-mode.trim 时,此时数据受控,当调用 setXX 函数改变数据时会触发 emit 函数并传递参数,假如此时传递的参数不兼容 trim(),就会报错
v-mode.trim
setXX
以上就是问题出现的原因
useVmodel 做兼容,当使用了 trim 修饰符时,对传递的参数做处理
vue 底层做兼容(我打算先给 vue 提个 issue,看能不能搞个 pr 😄)
完了,我这真实版丢人现眼,^^^^
上面的解决方式都不完全正确,合理的解决方案应该是:
emit('update:xxxx', newValue)
update:xxx
当然, vue 底层我个人觉得还是应该要做兼容的 vuejs/core#6711
No branches or pull requests
重现链接
https://stackblitz.com/edit/angular-ftdg2p?file=src%2Fdemo.vue
重现步骤
再组件的v-model上使用trim 将会造成input 内容被清空
期望结果
v-model.trim在使用频率上还是比较常用的,例如在用户登录 ,表单提交,搜索等地方都是需要将用户输入的内容去掉首尾空 防止后台验证不了数据
实际结果
已在vue3中使用原生input 测试,该bug 为组件bug
The text was updated successfully, but these errors were encountered: