Skip to content

Commit d4d437f

Browse files
authored
use async await for nextTick (vuejs#2366)
1 parent 1f28a6b commit d4d437f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/guide/essentials/reactivity-fundamentals.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,10 @@ To wait for the DOM update to complete after a state change, you can use the [ne
342342
```js
343343
import { nextTick } from 'vue'
344344

345-
function increment() {
345+
async function increment() {
346346
count.value++
347-
nextTick(() => {
348-
// access updated DOM
349-
})
347+
await nextTick()
348+
// Now the DOM is updated
350349
}
351350
```
352351

@@ -358,11 +357,10 @@ import { nextTick } from 'vue'
358357

359358
export default {
360359
methods: {
361-
increment() {
360+
async increment() {
362361
this.count++
363-
nextTick(() => {
364-
// access updated DOM
365-
})
362+
await nextTick()
363+
// Now the DOM is updated
366364
}
367365
}
368366
}

0 commit comments

Comments
 (0)