Skip to content

Commit ec0bff1

Browse files
NoelDeMartinposva
andauthored
docs: note about initial navigation and transitions (#2392) (#2397)
Co-authored-by: Eduardo San Martin Morote <[email protected]>
1 parent 2ddd19f commit ec0bff1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/docs/guide/advanced/transitions.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,17 @@ Vue might automatically reuse components that look alike, avoiding any transitio
8080
</router-view>
8181
```
8282

83-
<!-- TODO: interactive example -->
83+
## Initial navigation and transitions
84+
85+
Usually, enter animations are ignored by Vue's `<Transition>` unless we add the `appear` prop. But you'll notice that, when using it alongside `<RouterView>`, transitions are **always** applied despite the `appear` prop not being set. This is because navigations are asynchronous in Vue Router, meaning that the Vue application renders once before the initial navigation is finished. There are different ways to adapt this. The easiest one is to await the initial navigation before mounting the app with [`isReady`](https://router.vuejs.org/api/interfaces/Router.html#isReady):
86+
87+
```ts
88+
const app = createApp(App)
89+
app.use(router)
90+
91+
// mount after the initial navigation is ready
92+
await router.isReady()
93+
app.mount('#app')
94+
```
95+
8496
<!-- See full example [here](https://github.com/vuejs/vue-router/blob/dev/examples/transitions/app.js). -->

0 commit comments

Comments
 (0)