You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2019-03-25-vue-dom-diff.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,7 @@ res:edcba
144
144
### 例2:换序
145
145
146
146
old: a b c d e
147
+
147
148
new: a c e b d
148
149
149
150
```
@@ -199,6 +200,7 @@ res: acebd
199
200
### 例3:增加元素
200
201
201
202
old: a b c
203
+
202
204
new: a d b c
203
205
204
206
```
@@ -236,6 +238,7 @@ res:adbc
236
238
### 例4:增加元素
237
239
238
240
old: a b c
241
+
239
242
new: a c
240
243
241
244
```
@@ -346,10 +349,10 @@ if (child._mountIndex < lastIndex),则进行节点移动操作
346
349
347
350
> 1. 原生 DOM 操作 vs. 通过框架封装操作。这是一个性能 vs. 可维护性的取舍。框架的意义在于为你掩盖底层的 DOM 操作,让你用更声明式的方式来描述你的目的,从而让你的代码更容易维护。**没有任何框架可以比纯手动的优化 DOM 操作更快,因为框架的 DOM 操作层需要应对任何上层 API 可能产生的操作,它的实现必须是普适的**。针对任何一个 benchmark,我都可以写出比任何框架更快的手动优化,但是那有什么意义呢?在构建一个实际应用的时候,你难道为每一个地方都去做手动优化吗?出于可维护性的考虑,这显然不可能。框架给你的保证是,你在不需要手动优化的情况下,我依然可以给你提供过得去的性能。不要天真地以为 Virtual DOM 就是快,diff 不是免费的,batching 么 MVVM 也能做,而且最终 patch 的时候还不是要用原生 API
0 commit comments