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

[Bug Report] emoji 长度的计算和截取是有问题的 #13370

Open
HiWangyeah opened this issue Feb 27, 2025 · 0 comments
Open

[Bug Report] emoji 长度的计算和截取是有问题的 #13370

HiWangyeah opened this issue Feb 27, 2025 · 0 comments

Comments

@HiWangyeah
Copy link
Contributor

HiWangyeah commented Feb 27, 2025

重现链接

https://codesandbox.io/p/devbox/vant-4-issue-template-forked-52p8rr?file=%2Fsrc%2FApp.vue%3A8%2C12

Vant 版本

4.8.1

描述一下你遇到的问题。

看了当前源码中字符长度的计算,这种方法其实是有问题的。

[...'👩‍👩‍👧‍👦'] // ['👩', '‍', '👩', '‍', '👧', '‍', '👦']

重现步骤

如示例中所示,默认值是 👩‍👩‍👧‍👦,但因为限制了 maxlength,导致被截取成 👩‍👩。字符长度的问题,可以通过runes2来解决,但是这个包有点大。所以建议能够提供一个 api,供用户自己来提供方法计算长度和截取。看了目前的几个 bug,好几个都是和字符截取有关系🤣🤣

如果觉得新加 api 可行的话,我可以尝试提个 pr

设备/浏览器

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant