Skip to content

v-for中的ref问题 #11424

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

Closed
2840365628 opened this issue Jul 23, 2024 · 2 comments
Closed

v-for中的ref问题 #11424

2840365628 opened this issue Jul 23, 2024 · 2 comments

Comments

@2840365628
Copy link

Vue version

3.4.3

Link to minimal reproduction

https://play.vuejs.org/#eNqNVV1rE0EU/SvTfWmEdtNPhZgGqxasD1Wq4EO3D5vdyWaaycwyO5smhIViKbVaVHxRoWB9EKoUfRGsUfDPNIl98i94Zzabj6XWvoSZc889c+beu5Omsej7Zi3ERs7IB44gvkQBlqFfsBip+lxI1EQCl1CESoJX0ThQxy1mMYezQKJq4KEFFc+M38GUcvSIC+qOjV8ZULggHmG3bWkDc81iTYshVMTuCs+h6Qm18W1JMJPLLgAWiyaGGTNpxkyaMZtmzKYZc2kGCylNk+ZTpPM4Vy8jdO0fpHVVkqQoblwOVbhBfYaK5lDiVJaqvmwAK3MFLRSQPkPlmTWbhhjwQaZZIlRikSESVxV3TC3MvgcQjlLai5ReSnkkkzCGxSoMQ+x82G8ZO5VRQRXgFJuUe5kkMT5gbWo9dpTPxhMHswYbsOxTW2LYIZQvTxeaTT1fUZTPwk6jxVBKztANfYcFyxjUyTIK3Y+tdutpPhuTLkiAywO9vXN0tn00RD8/Qd1Ms590H39v7/6IT/nzc799cBQjsRAgnYOt9svnAHaO33f2985efe68+9A9eNY9Pj492To9+dTe2e5+PRxx2GwmxYmgIghpEy6pQZvsIFAGOJPQRbCgQqmgzrUMVJsscaH2agAI090EOFfBjR5q6vFUmCtsz7OLFENkLDUpEIfOJsJgCoDeudpqXyiKfv9623nzBUrRfvEtrp12l3QRLBEtlNLvq8U3KYDM2S5Ubu+01cpnFdKXyo5MRFod02AQGBV7ffh/sUE4WY1QYBvIBlVLs9eB3ndCAuA0cqhEcf26Qjzbh2dpyo93Cp7cFApTvwozdTHj9E3iyrKiJ/wyJl5ZDiNF26l4gofMnXQ45SKHfMIqOsR92yESDp8y5xUQwbjE31HPqzFhyAD8lohnbgScwauuj1VjVPUJxeKeLwl8mZaRiw2pmA0v9+ZdjUkRYv2A6Rw1++fgG0FdYZZxX+AAixq2jH5M2sLDMK0qvPRgBddh3Q9WuRtSYF8QXMXwaoTKY0y7CXUA20M87XZZ/zcR5j0MlurQnSC5lDKqmJHmWwb8X9264OoDu7PmnM6DihrRX8XOils=

Steps to reproduce

请先点击空床按钮,然后在点击全部按钮,最后点击查看元素的按钮,就可以在控制台查看ref的第一个元素

What is expected?

为什么数据刷新后,ref元素的下标不对,我发现当刷新数据时,只移除了不存在的dom的ref,而不是全部清除ref,当数据回到最初时候,那些移除的ref 都被push到了 innerRef数组的最后

What is actually happening?

请问为什么会这样?

System Info

No response

Any additional comments?

No response

@2840365628
Copy link
Author

在依次点击了按钮,并在控制台打印了ref的第一个元素之后,鼠标移入元素发现并不是当前视图中的第一个元素,

@edison1105
Copy link
Member

edison1105 commented Jul 23, 2024

It should be noted that the ref array does not guarantee the same order as the source array.

see document

workaround

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants