mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
927 B
927 B
title | description |
---|---|
<Teleport> | The <Teleport> component teleports a component to a different location in the DOM. |
::warning
The to
target of <Teleport>
expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to body
only, with client-side support for other targets using a <ClientOnly>
wrapper.
::
Body Teleport
<template>
<button @click="open = true">
Open Modal
</button>
<Teleport to="body">
<div v-if="open" class="modal">
<p>Hello from the modal!</p>
<button @click="open = false">
Close
</button>
</div>
</Teleport>
</template>
Client-side Teleport
<template>
<ClientOnly>
<Teleport to="#some-selector">
<!-- content -->
</Teleport>
</ClientOnly>
</template>
:link-example{to="/docs/examples/advanced/teleport"}