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] 52. diff 算法 #443

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

[vue] 52. diff 算法 #443

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

Comments

@qiilee
Copy link
Member

qiilee commented Oct 8, 2019

No description provided.

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

diff算法包括一下几个步骤:

用 JavaScript 对象结构表示 DOM 树的结构;然后用这个树构建一个真正的 DOM 树,插到文
档当中

当状态变更的时候,重新构造一棵新的对象树。然后用新的树和旧的树进行比较(diff),记录两棵树差异
把2所记录的差异应用到步骤1所构建的真正的DOM树上(patch),视图就更新了
diff算法是通过同层的树节点进行比较而非对树进行逐层搜索遍历的方式,所以时间复杂度只有O(n),是一种相当高效的算法。

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