Skip to content

Commit 266b7f7

Browse files
MaynessNataliaTepluhina
authored andcommitted
Update reactivity.md (#2134)
* Update reactivity.md Change the compatibility priority of nextTick * Update src/v2/guide/reactivity.md Co-Authored-By: Mayness <[email protected]>
1 parent f5ca787 commit 266b7f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/v2/guide/reactivity.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ There are technical reasons behind this restriction - it eliminates a class of e
7777

7878
## Async Update Queue
7979

80-
In case you haven't noticed yet, Vue performs DOM updates **asynchronously**. Whenever a data change is observed, it will open a queue and buffer all the data changes that happen in the same event loop. If the same watcher is triggered multiple times, it will be pushed into the queue only once. This buffered de-duplication is important in avoiding unnecessary calculations and DOM manipulations. Then, in the next event loop "tick", Vue flushes the queue and performs the actual (already de-duped) work. Internally Vue tries native `Promise.then` and `MessageChannel` for the asynchronous queuing and falls back to `setTimeout(fn, 0)`.
80+
In case you haven't noticed yet, Vue performs DOM updates **asynchronously**. Whenever a data change is observed, it will open a queue and buffer all the data changes that happen in the same event loop. If the same watcher is triggered multiple times, it will be pushed into the queue only once. This buffered de-duplication is important in avoiding unnecessary calculations and DOM manipulations. Then, in the next event loop "tick", Vue flushes the queue and performs the actual (already de-duped) work. Internally Vue tries native `Promise.then`, `MutationObserver`, and `setImmediate` for the asynchronous queuing and falls back to `setTimeout(fn, 0)`.
8181

8282
For example, when you set `vm.someData = 'new value'`, the component will not re-render immediately. It will update in the next "tick", when the queue is flushed. Most of the time we don't need to care about this, but it can be tricky when you want to do something that depends on the post-update DOM state. Although Vue.js generally encourages developers to think in a "data-driven" fashion and avoid touching the DOM directly, sometimes it might be necessary to get your hands dirty. In order to wait until Vue.js has finished updating the DOM after a data change, you can use `Vue.nextTick(callback)` immediately after the data is changed. The callback will be called after the DOM has been updated. For example:
8383

0 commit comments

Comments
 (0)