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

[vue] 14. vue 中 key 值的作用 #405

Open
qiilee opened this issue Oct 8, 2019 · 1 comment
Open

[vue] 14. vue 中 key 值的作用 #405

qiilee opened this issue Oct 8, 2019 · 1 comment
Labels

Comments

@qiilee
Copy link
Member

qiilee commented Oct 8, 2019

答案:

需要使用 key 来给每个节点做一个唯一标识,Diff 算法就可以正确的识别此节点,找到正确的位置区插入新的节点
所以一句话,key 的作用主要是为了高效的更新虚拟 DOM

@qiilee qiilee added the VUE label Oct 8, 2019
@tnnevol
Copy link

tnnevol commented May 14, 2024

key 值小技巧,可以通过变动key做到重新初始化组件

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

No branches or pull requests

2 participants