Skip to content

atinput组件输入单个字符后光标跳到最前边 #1836

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

Open
1066511239 opened this issue Mar 13, 2025 · 8 comments
Open

atinput组件输入单个字符后光标跳到最前边 #1836

1066511239 opened this issue Mar 13, 2025 · 8 comments

Comments

@1066511239
Copy link

正常运行的微信小程序,过一段时间atinput组件就出现输入单个字符后光标跳到最前边

@jufang
Copy link

jufang commented Mar 14, 2025

请问你怎么处理这个问题的,我也遇到这个问题了

@jufang
Copy link

jufang commented Mar 14, 2025

给每个AtInput 加cursor=-1

@honeywong
Copy link

他这个是为什么呢?

@yang0124
Copy link

原因是什么呢,搞不懂

@alleluya7519
Copy link

给每个AtInput 加cursor=-1

AtInput会倒着输入是因为这个问题吗? 我GitHub上搜了下taro的issue 看这个问题好像几年前就有提过 有说是微信版本也有问题, 这个问题和taro-ui的版本 taro版本跟微信版本都有关系? 还是说我只要加cursor=-1就可以完全解决的

@ramey502
Copy link

cursor={value.length}就可以

@Asuler
Copy link

Asuler commented Apr 17, 2025

@ramey502 cursor={value.length} 是不行的,这样做只是输入的时候可以,但是如果你光标定到中间部分,删除几个字,你会发现自动跳到最后了,又会产生新问题

@Asuler
Copy link

Asuler commented Apr 17, 2025

用Taro自带的input是可以的,但是taro-ui的AtInput不行,因为AtInput源码里默认给cursor加了一个0 的默认值,而支付宝或者微信小程序的文档里,cursor的默认值是空而不是0,所以给一个cursor=-1的无效值去覆盖atinput的默认cursor值。 猜测是因为setState的时候不知道为什么把AtInput组件也给刷新了,导致render时每次cursor都使用默认值0

Sorry, something went wrong.

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

No branches or pull requests

7 participants