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

第210题(2020-05-11):react 与 vue 数组中 key 的作用是什么?(阿里) #212

Open
qappleh opened this issue May 11, 2020 · 1 comment

Comments

@qappleh
Copy link
Owner

qappleh commented May 11, 2020

No description provided.

@qappleh
Copy link
Owner Author

qappleh commented May 12, 2020

diff算法需要比对虚拟dom的修改,然后异步的渲染到页面中,当出现大量相同的标签时,vnode会首先判断key和标签名是否一致,如果一致再去判断子节点一致,使用key可以帮助diff算法提升判断的速度,在页面重新渲染时更快消耗更少。

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