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
-[Some transition classes got a rename](/guide/migration/transition.html)
95
-
-[Component watch option](/api/options-data.html#watch)and [instance method `$watch`](/api/instance-methods.html#watch)no longer supports dot-delimited string paths, use a computed function as the parameter instead.
95
+
-When using [the `watch` option](/api/options-data.html#watch)to watch an array, the callback will only trigger when the array is replaced, and no longer trigger on array mutation. To trigger on mutation, the `deep` option must be specified. This is a side effect of more precise dependency tracking in Vue 3.
96
96
-`<template>` tags with no special directives (`v-if/else-if/else`, `v-for`, or `v-slot`) are now treated as plain elements and will result in a native `<template>` element instead of rendering its inner content.
97
97
- In Vue 2.x, application root container's `outerHTML` is replaced with root component template (or eventually compiled to a template, if root component has no template/render option). Vue 3.x now uses application container's `innerHTML` instead - this means the container itself is no longer considered part of the template.
Copy file name to clipboardExpand all lines: src/guide/reactivity-computed-watchers.md
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ An async function implicitly returns a Promise, but the cleanup function needs t
93
93
94
94
### Effect Flush Timing
95
95
96
-
Vue's reactivity system buffers invalidated effects and flushes them asynchronously to avoid unnecessary duplicate invocation when there are many state mutations happening in the same "tick". Internally, a component's `update` function is also a watched effect. When a user effect is queued, it is always invoked after all component `update` effects:
96
+
Vue's reactivity system buffers invalidated effects and flushes them asynchronously to avoid unnecessary duplicate invocation when there are many state mutations happening in the same "tick". Internally, a component's `update` function is also a watched effect. When a user effect is queued, it is by default invoked **before** all component `update` effects:
97
97
98
98
```html
99
99
<template>
@@ -120,7 +120,7 @@ Vue's reactivity system buffers invalidated effects and flushes them asynchronou
120
120
In this example:
121
121
122
122
- The count will be logged synchronously on initial run.
123
-
- When `count` is mutated, the callback will be called **after** the component has updated.
123
+
- When `count` is mutated, the callback will be called **before** the component has updated.
124
124
125
125
Note the first run is executed before the component is mounted. So if you wish to access the DOM (or template refs) in a watched effect, do it in the `onMounted` hook:
126
126
@@ -132,7 +132,7 @@ onMounted(() => {
132
132
})
133
133
```
134
134
135
-
In cases where a watcher effect needs to be re-run synchronously or before component updates, we can pass an additional `options` object with the `flush` option (default is `'post'`):
135
+
In cases where a watcher effect needs to be re-run synchronously or after component updates, we can pass an additional `options` object with the `flush` option (default is `'pre'`):
136
136
137
137
```js
138
138
// fire synchronously
@@ -145,13 +145,15 @@ watchEffect(
145
145
}
146
146
)
147
147
148
-
// fire before component updates
148
+
// fire after component updates so you can access the updated DOM
149
+
// Note: this will also defer the initial run of the effect until the
0 commit comments