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

v-lazy元素被复用。导致图片出现在错误的元素上。 #517

Open
miaowwwww opened this issue Jun 5, 2024 · 1 comment
Open

Comments

@miaowwwww
Copy link

企业微信截图_b7ed680b-d622-47ab-a2e1-35ee5dc666ba 如图:v-lazy的兄弟节点存在v-if改变元素数量, 3s后,背景图会出现在两个元素中
@miaowwwww
Copy link
Author

根本原因就是vIf导致元素被复用。
方案1. 最简单的方式是在使用指令的地方加一个key。缺点就是这个key,与业务无关。人为控制很容易被遗漏
方案2. 在unbind事件中,把元素复原。例如把ele.remove('background-image')

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

1 participant