Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document appear transition behaviour (#2392) #2397

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/docs/guide/advanced/transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,23 @@ Vue might automatically reuse components that look alike, avoiding any transitio
</router-view>
```

## Respecting `appear` transitions behaviour

Usually, enter animations are ignored on the initial render unless you're using the `appear` prop. But you'll notice that route components don't respect this behaviour. This happens because the route component is not available in the initial render.

You can fix this by making sure that the `<transition>` component isn't rendered until the first route component has been loaded:

```vue-html
<router-view v-slot="{ Component }">
<transition v-if="Component" name="fade">
<component :is="Component" />
</transition>
</router-view>
```

Alternatively, you can also await on the router's [`isReady`](https://router.vuejs.org/api/interfaces/Router.html#isReady) method which returns a promise.

Finally, you can support for more complex scenarios [combining the `<Suspense>` and `<KeepAlive>` components](https://vuejs.org/guide/built-ins/suspense.html#combining-with-other-components).

<!-- TODO: interactive example -->
<!-- See full example [here](https://github.com/vuejs/vue-router/blob/dev/examples/transitions/app.js). -->